Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Age... and Segmentation Fault

Age... and Segmentation Fault

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Raeyu   (3 posts)  Bio
Date Thu 15 May 2003 10:16 AM (UTC)
Message
I'm trying to add customizable age, like "age 20" to set your age, and I've gotten it so far, by uh, copying the icq command in the finger file, and doing some other stuff my friends suggested, but it came out like crap and now you can only set your age higher than 60 ONCE, no less, and when you type age to see your current age, it comes out like 5840 for 90, and if you set 60, it comes out like 41.. That, and it won't write it to the pfile, like the icq command does.. Here's the crapped out code:

void do_age( CHAR_DATA *ch, char *argument )
{
int age;

if ( IS_NPC( ch ) )
return;

if ( argument[0] == '\0' )
{
if ( !ch->pcdata->age )
ch->pcdata->age = 5;
ch_printf( ch, "Your age is: %o\n\r", ch->pcdata->age );
return;
}

if ( !is_number( argument ) )
{
send_to_char( "You must enter numeric data.\n\r", ch );
return;
}

age = atoi( argument );

if ( age < 5 )
{
send_to_char( "Valid range is 4-90.\n\r", ch );
return;
}

if ( age > 90 )
{
send_to_char( "Valid range is 4-90.\n\r", ch );
return;
}


ch->pcdata->age = age;

if ( IS_IMMORTAL( ch ) );
{
save_char_obj( ch );
build_wizinfo( FALSE );
}

send_to_char( "Age set.\n\r", ch );
return;
}
Top

Posted by Dave   Australia  (93 posts)  Bio
Date Reply #1 on Thu 15 May 2003 12:01 PM (UTC)
Message
A few things..

1. "Your age is %o\n\r" should be "Your age is %d\n\r". The %o means octal.

2. You need to remove the ; from: if (IS_IMMORTAL(ch)); and possibly put the save_char_obj() outside of the if, so not just immortals are saved.

3. The reason it's not saving on the pfile is probably because you need to also add relevant code to save.c, probably in fread_char() and fwrite_char() (I hope they're the functions, I've never used SMAUG).

4. If the valid range is 4-90, then you need to use if (age < 4) not < 5.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


10,753 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.