Need help with checking if a players been afk longer than 15 mins :D
#2

pawn Код:
// After #includes

new
    pAFKTimer[ MAX_PLAYERS ],
    isAFK[ MAX_PLAYERS ]
;

// OnPlayerConnect

pAFKTimer[ playerid ] = SetTimerEx( "getAFK", 900000, true, "i", playerid );
isAFK[ playerid ] = 0;

// OnPlayerUpdate

if ( isAFK[ playerid ] == 1 )
{
    new
        szString[ 128 ]
    ;

    format( szString, sizeof szString, "* %s is now back on the server.", getpName( playerid ) );

    SendClientMessageToAll( 0xFFFFFFAA, szString );
}

KillTimer( pAFKTimer[ playerid ] );
pAFKTimer[ playerid ] = SetTimerEx( "getAFK", 900000, true, "i", playerid );

// Add this somewhere on your script ( not in a callback / function ).

stock getpName( playerid )
{
    new
        pName[ 24 ]
    ;

    return GetPlayerName( playerid, pName, sizeof pName ), pName;
}

forward getAFK( playerid ); public getAFK( playerid )
{
    new
        szString[ 128 ]
    ;

    format( szString, sizeof szString, "* %s is now AFK.", getpName, playerid );

    SendClientMessageToAll( 0xFFFFFFAA, szString );

    isAFK[ playerid ] = 1;

    return 1;
}
Honestly, I don't know will that works or not, but you'll need to test it.
Reply


Messages In This Thread
Need help with checking if a players been afk longer than 15 mins :D - by peterRook - 21.06.2011, 03:09
Re: Need help with checking if a players been afk longer than 15 mins :D - by Basicz - 21.06.2011, 03:39

Forum Jump:


Users browsing this thread: 1 Guest(s)