03 Jan, 2012, thecircuitbox wrote in the 1st comment:
Votes: 0
ACMD(do_finger)
{
struct time_info_data playing_time;

const char *immlevels[LVL_IMPL - (LVL_IMMORT-1)] = {
"[Wizard]", /* highest mortal level +1 */
"[Senior Wizard]", /* highest mortal level +2 */
"[Arch Wizard]", /* highest mortal level +3 */
"[God]", /* highest mortal level +4 */
};



struct char_data *victim = 0;
skip_spaces(&argument);

if (!*argument) {
send_to_char(ch, "Who?\r\n");
} else {
CREATE(victim, struct char_data, 1);
clear_char(victim);
CREATE(victim->player_specials, struct player_special_data, 1);
if (load_char(argument, victim) >= 0) {
playing_time = *real_time_passed((time(0) - ch->player.time.logon) + ch->player.time.played, 0);
if (GET_LEVEL(victim) >= LVL_IMMORT)
send_to_char(ch, "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n %s %s %s\r\n Status: %d (%s Level)\r\n Married to: N/A\r\n Clan enrollment: N/A\r\n Age : %d day%s %d hour%s\r\n Last logged at: N/A\r\n Email address: N/A\r\n N?A has (no) unread mail.\r\n N?A is not logged on.\r\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n", GET_NAME(victim), GET_TITLE(victim), GET_ALIGNMENT(victim), immlevels[GET_LEVEL(victim)-LVL_IMMORT], GET_LEVEL(victim), playing_time.day, playing_time.day == 1 ? "" : "s", playing_time.hours, playing_time.hours == 1 ? "" : "s");
else
send_to_char(ch, "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n"
" %s %s %s \r\n", GET_NAME(victim), GET_TITLE(victim), GET_ALIGNMENT(victim),
" Status: %s (%d Level) \r\n", GET_CLASS(victim), GET_LEVEL(victim),
" Married to: N/A \r\n"
" Clan enrollment: N/A \r\n"
" Age : %d day%s %d hour%s \r\n", playing_time.day, playing_time.day == 1 ? "" : "s", playing_time.hours, playing_time.hours == 1 ? "" : "s"),
" Last logged at: N/A \r\n"
" Email address: N/A \r\n"
" %s has (no) unread mail."
" %s is not logged on."
"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n");
} else {
send_to_char(ch, "There is no such player.\r\n");
}
free(victim);
}
}


This code keeps crashing the mud. :ghostface:
03 Jan, 2012, thecircuitbox wrote in the 2nd comment:
Votes: 0
ACMD(do_finger)
{
const char *immlevels[LVL_IMPL - (LVL_IMMORT-1)] = {
"Wizard", /* highest mortal level +1 */
"Senior Wizard", /* highest mortal level +2 */
"Arch Wizard", /* highest mortal level +3 */
"God", /* highest mortal level +4 */
};

struct time_info_data playing_time;
struct char_data *victim = 0;
skip_spaces(&argument);

if (!*argument) {
send_to_char(ch, "Who?\r\n");
} else {
CREATE(victim, struct char_data, 1);
clear_char(victim);
CREATE(victim->player_specials, struct player_special_data, 1);
playing_time = *real_time_passed((time(0) - ch->player.time.logon) + ch->player.time.played, 0);
if (load_char(argument, victim) >= 0) {
if (GET_LEVEL(victim) >= LVL_IMMORT)
send_to_char(ch, "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n %s %s\r\n Status: %s\r\n Married to: N/A\r\n Clan enrollment: N/A\r\n Age : %d day%s %d hour%s\r\n Last logged at: N/A\r\n Email address: N/A\r\n Player has (no) unread mail.\r\n Player is not logged on.\r\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n", GET_NAME(victim), GET_TITLE(victim), immlevels[GET_LEVEL(victim)-LVL_IMMORT], playing_time.day, playing_time.day == 1 ? "" : "s", playing_time.hours, playing_time.hours == 1 ? "" : "s");
else
send_to_char(ch, "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n %s %s\r\n Status: %d %d\r\n Married to: N/A\r\n Clan enrollment: N/A\r\n Age : %d day%s %d hour%s\r\n Last logged at: N/A\r\n Email address: N/A\r\n Player has (no) unread mail.\r\n Player is not logged on.\r\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n", GET_NAME(victim), GET_TITLE(victim), GET_CLASS(victim), GET_LEVEL(victim), playing_time.day, playing_time.day == 1 ? "" : "s", playing_time.hours, playing_time.hours == 1 ? "" : "s");
} else {
send_to_char(ch, "There is no such player.\r\n");
}
free(victim);
}
}


So Now it does not crash but the class name does not show up.
03 Jan, 2012, Zeno wrote in the 3rd comment:
Votes: 0
What does gdb say about the crash?
03 Jan, 2012, thecircuitbox wrote in the 4th comment:
Votes: 0
It does not crash anymore. The only problem I am now having is it does not show the Class name.

This is what i want it to look like:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Foobar the Swordpupil
Status: Death Knight 99 <—(THIS Class / LEVEL)
Married to: Birgitte
Clan enrollment: The Saints
Age : 0 days 5 hours
Last logged at: Sun Dec 31 03:41:57 2011 from: c-??-???-???-??.hsd1.tx.comcast.net
Email address: ???????@????.???
He has no unread mail.
He is not logged on.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


This is what it looks like:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Foobar the Swordpupil
Status: 9 99 <—(THIS Class / LEVEL(shows class number instead of class name))
Married to: Birgitte
Clan enrollment: The Saints
Age : 0 days 5 hours
Last logged at: Sun Dec 31 03:41:57 2011 from: c-??-???-???-??.hsd1.tx.comcast.net
Email address: ???????@????.???
He has no unread mail.
He is not logged on.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


As you can see only the level shows up.
03 Jan, 2012, Sharmair wrote in the 5th comment:
Votes: 0
Like you said in that last post, you are printing the class number instead
of the class name. If you have an array of the class names (in one circleMUD
I helped on, the array was called pc_class_types and was defined in class.c)
you would just change the %d to %s in the class spot in your format string,
and make the data something like pc_class_types[GET_CLASS(victim)].
Though it would be a good idea to maybe put the get class name in a function
and also do some range checking so you don't have issues with an out of
range class on a player. If you don't know what to use, look at other places
in the code that print the class and see how it looks it up.
03 Jan, 2012, thecircuitbox wrote in the 6th comment:
Votes: 0
Sweet thank you
0.0/6