The forums will be going offline for an extended maintenance period at 1400hrs GMT on 19th June 2025. The number of hours for this downtime is intentionally not advertised due to the nature of these upgrades.
×
- 0
Updating @stats - Using string variables (words) to replace number variables?
-
Recently Browsing 0 members
- No registered users viewing this page.
Question
Humble_Bee
Howdy all. I'm working on updating @stats on my server to show more useful info (I'm not finished with what I want yet, but I'm adding bit by bit). Can someone tell me how I can get this table to pop up the elements, race, and etc instead of numbers? I am able to show my armor element in-game already as a number (Neutral shows as 0, Water shows as 1, etc), but I want it to show a word instead. I think I'm getting close, as the debugger only shows "term does not evaluate to a function taking 1 arguments" as my only error. I just don't know how to finish it. Of course, if you have an easier way so a @stat changes a number variable into a word when it outputs the text in chat, I'm open to that as well. Here is my code:
ACMD_FUNC(stats)
{
unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
char job_jobname[100];
char element[8];
char output[CHAT_SIZE_MAX];
int i;
struct {
const char* format;
char details;
int value;
} output_table[] = {
{ "Base Level - %d", 0 },
{ NULL, 0 },
{ "Perfect Dodge - %3d", 0 },
{ "Perfect Hit- %3d", 0 },
{ "Crit Attack Bonus - %3d", 0 },
{ "Armor Element - %u", 0 },
{ "HP Regen Rate- %d", 0 },
{ "SP Regen Rate- %d", 0 },
{ "Race - %u", 0 },
{ "Size - %u", 0 },
{ NULL, 0 },
{ "Zeny also - %d", 0 },
{ "Zeny - %d", 0 },
{ "Free SK Points - %d", 0 },
{ "JobChangeLvl (2nd) - %d", 0 },
{ "JobChangeLvl (3rd) - %d", 0 },
{ NULL, 0 }
};
memset(element, '\0', sizeof(element));
memset(job_jobname, '\0', sizeof(job_jobname));
memset(output, '\0', sizeof(output));
//direct array initialization with variables is not standard C compliant.
output_table[0].value = sd->status.base_level;
output_table[1].format = job_jobname;
output_table[1].value = sd->status.job_level;
output_table[2].value = sd->battle_status.flee2/10;
output_table[3].value = sd->bonus.perfect_hit_add;
output_table[4].value = sd->bonus.crit_atk_rate;
output_table[5].value = sd->battle_status.def_ele;
output_table[6].value = sd->hprecov_rate;
output_table[7].value = sd->sprecov_rate;
output_table[8].value = sd->battle_status.race;
output_table[9].value = sd->battle_status.size;
output_table[10].format = element;
output_table[10].value = sd->battle_status.ele_lv;
output_table[11].value = sd->status.zeny;
output_table[12].value = sd->status.zeny;
output_table[13].value = sd->status.skill_point;
output_table[14].value = sd->change_level_2nd;
output_table[15].value = sd->change_level_3rd;
sprintf(element(melement[sd->battle_status.def_ele]), "Element: %s", sd->battle_status.ele_lv, "(Level %u)");
sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
clif_displaymessage(fd, output);
for (i = 0; output_table.format != NULL; i++) {
sprintf(output, output_table.format, output_table.value);
clif_displaymessage(fd, output);
}
return 0;
}
The only line it throws the error I mentioned on is this one:
sprintf(element(melement[sd->battle_status.def_ele]), "Element: %s", sd->battle_status.ele_lv, "(Level %u)");
Thanks for anyone familiar with the C++ code!
Edited by Humble_BeeLink to comment
Share on other sites
8 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.