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 ➜ AFK oddity, help anyone?

AFK oddity, help anyone?

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


Posted by Gatewaysysop2   USA  (146 posts)  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
Top

Posted by Gatewaysysop2   USA  (146 posts)  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
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.


9,759 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.