[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  AFK oddity, help anyone?

AFK oddity, help anyone?

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


Posted by Gatewaysysop2   USA  (146 posts)  [Biography] bio
Date Sun 06 Jul 2003 10:11 PM (UTC)
Message
I have this AFK code, found in some distrubtion of Smaug1.4aR4 I think(?) but it has a bug. For some reason, when you are already AFK and you type "afk" it will say

"you are no longer flagged as being away"
"you are now away"

Clearly this isn't right. As with all other activity, typing in "afk" should simply drop you back out of being afk and leave it at that, no drop you out and throw you right back into it. Here's the code that's giving me trouble.



void do_afk( CHAR_DATA *ch, char *argument )
{
    if ( IS_NPC(ch) )
        return;

    if xIS_SET(ch->act, PLR_AFK)
    {
        xREMOVE_BIT(ch->act, PLR_AFK);
        if( ch->pcdata->afkmsg )
        {
            STRFREE( ch->pcdata->afkmsg );
            ch->pcdata->afkmsg = NULL;
        }
        send_to_char( "You are no longer away.\n\r", ch );
        act(AT_GREY,"$n is no longer away.", ch, NULL, NULL, TO_CANSEE);
    }
    else
    {
        if( strlen( argument ) > 50 )
        {
            send_to_char( "Message is too long. Try to keep under 50 characters.\n\r", ch );
            return;
        }
        
        xSET_BIT(ch->act, PLR_AFK);
         
        if( argument[0] != '\0')
        {
            char buf[MAX_INPUT_LENGTH];
        
            sprintf( buf, " (%s) ", argument );
            ch->pcdata->afkmsg = STRALLOC( buf );
            ch_printf( ch, "You are now away: (%s)\n\r", argument );
            act(AT_GREY,"$n is now away: ($t).", ch, argument, NULL, TO_CANSEE);
        }
        else
        {
            send_to_char( "You are now away.\n\r", ch );
            act(AT_GREY,"$n is now away.", ch, NULL, NULL, TO_CANSEE);
        }
        return;
    }
}



Any ideas on why this isn't working quite right? I've stuck in a return; in a few places trying to fix this, but to no avail. Help is appreciated.


"The world of men is dreaming, it has gone mad in its sleep, and a snake is strangling it, but it can't wake up." -D.H. Lawrence
[Go to top] top

Posted by Gatewaysysop2   USA  (146 posts)  [Biography] bio
Date Reply #1 on Sun 06 Jul 2003 10:59 PM (UTC)

Amended on Mon 07 Jul 2003 07:59 PM (UTC) by Gatewaysysop2

Message
Found the fix for this, was looking in the wrong place (newbie, go figure).

Leave the do_afk code as is, go into interp.c and find this:



        /*
         * Turn off afk bit when any command performed. - Ntanel
         */
        if( xIS_SET ( ch->act, PLR_AFK ) && !IS_NPC( ch ))
        {
            xREMOVE_BIT( ch->act, PLR_AFK );
            if( ch->pcdata->afkmsg )
            {
                STRFREE( ch->pcdata->afkmsg );
                ch->pcdata->afkmsg = NULL;
            }
            act( AT_GREY, "$n is no longer away.", ch, NULL, NULL, TO_CANSEE );
            send_to_char("You are no longer flagged as being away.\r\n", ch);
        }
    }



Just change the "&& !IS_NPC( ch ))" to read: "&& (str_cmp(command, "AFK")) && !IS_NPC( ch )) "



"The world of men is dreaming, it has gone mad in its sleep, and a snake is strangling it, but it can't wake up." -D.H. Lawrence
[Go to top] 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.


8,578 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]