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 ➜ I Need Help With a New Variable...

I Need Help With a New Variable...

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


Posted by Seifz   (24 posts)  Bio
Date Sun 22 Feb 2004 03:21 AM (UTC)
Message
I seem to always have trouble with simple things. Usually I end up figuring it out but I just can't get this one to work. Basically, I want to add another variable to do_who in act_info.c that counts the total number of players logged on, regardless of the argument given with 'who'. For instance, let's assume that 5 mortals and 3 immortals are logged on. When a player types 'who imm' it should display the list of immortals and then, at the end, say "3 players listed, 8 online." Where do I put this variable? The whole function is just confusing to me.
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #1 on Sun 22 Feb 2004 03:57 AM (UTC)
Message
I'm using SWR, but there should be a part that looks like this:
    for ( d = last_descriptor; d; d = d->prev )
    {
	CHAR_DATA *wch;
	char const *race;

	if ( (d->connected != CON_PLAYING && d->connected != CON_EDITING )
	|| ( !can_see_ooc( ch, d->character ) && IS_IMMORTAL( d->character ) )
	|| d->original)
	    continue;
	wch   = d->original ? d->original : d->character;
	if ( wch->top_level < iLevelLower
	||   wch->top_level > iLevelUpper 
	|| ( fImmortalOnly  && wch->top_level < LEVEL_IMMORTAL ))
	    continue;

A part where they are looping through the desciptors. Just declare a count variable at the top of do_whom, initialize it to 0, and add that code add this:
++count;
Then, find the part that prints out how many people, and add the second part using count.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Seifz   (24 posts)  Bio
Date Reply #2 on Sun 22 Feb 2004 04:03 AM (UTC)
Message
Yeah, I've tried adding it to various places within that part... But I haven't been successful yet. I really need an exact location with this.

Also, should I use ++count or count++? I was trying it with count++ before.
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #3 on Sun 22 Feb 2004 04:07 AM (UTC)
Message
if all your doing is count++;, it doesn't matter is the ++ is a suffix or a prefix, it will do the same thing.

If you can post that part up from your code, I can show you were to put it. As well as the "# of players" part or your code.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Seifz   (24 posts)  Bio
Date Reply #4 on Sun 22 Feb 2004 04:46 AM (UTC)
Message
I declared nTotal as an int with the other variables and then set it to 0 right below the line that sets nMatch to 0. Also, the display part itself is fine:

if ( !ch )
{
fprintf( whoout, "\n\r%d player%s listed, %d online.\n\r", nMatch, nMatch == 1 ? "" : "s", nTotal );
fclose( whoout );
return;
}

set_char_color( AT_YELLOW, ch );
ch_printf( ch, "\n\r%d player%s listed, %d online.\n\r", nMatch, nMatch == 1 ? "" : "s", nTotal );
return;
}

It's getting nTotal to count every character logged in that I can't seem to do... Where in the whole huge loop thing to I put it? I haven't edited that part of the function, so it should match the default SMAUG 1.4a code... Which probably hasn't changed much in SWR.
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #5 on Sun 22 Feb 2004 04:50 AM (UTC)
Message
I've looked at the smaugfuss do_who... what a mess. Compared to the SWR, that is. However, look for this code:
	CHAR_DATA *wch;
	char const *class;

	if ( (d->connected != CON_PLAYING && d->connected != CON_EDITING)
	||   !can_see( ch, d->character ) || d->original)
	    continue;
        nTotal++;


And add the bold part. That SHOULD be all you have to do, but I don't know for sure.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Seifz   (24 posts)  Bio
Date Reply #6 on Sun 22 Feb 2004 05:00 AM (UTC)
Message
It works. Most excellent. Thanks for the help!

And yeah, it is a mess. I've considered stealing the SWR do_who equivalent and editing from there.
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.


20,348 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.