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
➜ >= doesnt seem to be working
|
>= doesnt seem to be working
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Rob Harper
(108 posts) Bio
|
| Date
| Fri 26 Sep 2003 07:01 PM (UTC) Amended on Fri 26 Sep 2003 07:12 PM (UTC) by Rob Harper
|
| Message
| I'v been posting up a storm as of late, hope you guys can help me with this one too. My mud works on sublevels in a way and as a convience I tried to add a quick little gauge to let the players know how in a roundabout way close they are to the next sublevel. But it doesnt seem to be working?
The way I have it laid out is somthing like:
void do_stat( CHAR_DATA *ch, char *argument )
{
char buf[MAX_STRING_LENGTH];
if (ch->level >= 2)
sprintf(buf, "20 to ");
else if (ch->level >= 4)
sprintf(buf, "40 to ");
else if (ch->level >= 6)
sprintf(buf, "60 to ");
else if (ch->level >= 8)
sprintf(buf, "80 to ");
else if (ch->level >= 10)
sprintf(buf, "0 to ");
else if (ch->level >= 12)
sprintf(buf, "20 to ");
else if (ch->level >= 14)
sprintf(buf, "40 to ");
else if (ch->level >= 16)
sprintf(buf, "60 to ");
else if (ch->level >= 18)
sprintf(buf, "80 to ");
else if (ch->level >= 20)
sprintf(buf, "0 to ");
And it continues on like that then I somthing like this at the very bottom.
pager_printf(ch, "Precent to better Build: %s \n\r", buf );
Kind of slopy I know but I figured it would do the job for now, but it doesnt seem to be working? The "# to whatever level never changes". I guess it's another one of those things that when someone points me in the right directions it'll make me a much better coder heh. But till then it puzzles me as to why it's not working seems simple enough.
Thanks | | Top |
|
| Posted by
| David Haley
USA (3,881 posts) Bio
|
| Date
| Reply #1 on Fri 26 Sep 2003 07:38 PM (UTC) |
| Message
| Well, work through your code logically. Let's assume that ch->level is equal to 15.
We come on to your ifcheck, and the very first check is:
if ( ch->level >= 2 )
This results in true, and therefore none of the else checks/blocks are even looked at.
What you want to do is have it the other way around: first check for the highest numbers, and go down.
e.g.
if ( ch->level >= 20 )
// do something
else if ( ch->level >= 18 )
// do something
else if ( ch->level >= 16 )
// do something
/* etc. */
This way, it'll "trigger" the right ifcheck (if I may use that word) and so you won't end up matching on the very first one. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | | Top |
|
| Posted by
| Rob Harper
(108 posts) Bio
|
| Date
| Reply #2 on Fri 26 Sep 2003 07:40 PM (UTC) |
| Message
| Oh my, I feel like such a ditz now. I had no idea the order had anything to do with it, thanks for the help.
Thanks again | | 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.
12,808 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top