Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- "afkSystem"
- A simple AFK system
- Made by greentarch -> 2/10/2013
- */
- #include < a_samp >
- #include < zcmd >
- new
- bool: gPlayerAFK[ MAX_PLAYERS char ],
- afkReason[ MAX_PLAYERS ][ 128 ],
- pVirtualWorld[ MAX_PLAYERS ]
- ;
- public OnPlayerConnect( playerid )
- return gPlayerAFK{ playerid } = false;
- public OnPlayerText( playerid, text[ ] ) {
- if ( gPlayerAFK{ playerid } ) {
- SendClientMessage( playerid, -1, "You cannot chat if you are in AFK status." );
- SendClientMessage( playerid, -1, "Use {00FFFF}/back {FFFFFF}if you are back from AFK." );
- return 0;
- }
- return 1;
- }
- CMD:afk( playerid, params[ ] ) {
- if ( gPlayerAFK{ playerid } )
- return SendClientMessage( playerid, -1, "You are already AFK. Use {00FFFF}/back {FFFFFF}instead." ), 1;
- if ( isnull( params ) )
- return SendClientMessage( playerid, -1, "Valid syntax : {00FFFF}/afk < reason >" );
- gPlayerAFK{ playerid } = true;
- new
- str[ 128 ],
- pName[ MAX_PLAYER_NAME ]
- ;
- format( afkReason[ playerid ], 128, "%s", params );
- GetPlayerName( playerid, pName, sizeof pName );
- format( str, sizeof str, "AFK >> {00FFFF}%s ( %d ) {FFFFFF}is now AFK. Reason : {00FFFF}%s",
- pName, playerid, params );
- SendClientMessageToAll( -1, str );
- SendClientMessage( playerid, -1, "You are now AFK. Use {00FFFF}/back {FFFFFF}if you have returned." );
- TogglePlayerControllable( playerid, 0 );
- pVirtualWorld[ playerid ] = GetPlayerVirtualWorld( playerid );
- SetPlayerVirtualWorld( playerid, playerid );
- return 1;
- }
- CMD:back( playerid, params[ ] ) {
- if ( !gPlayerAFK{ playerid } )
- return SendClientMessage( playerid, -1, "You are not in AFK status." );
- gPlayerAFK{ playerid } = false;
- new
- str[ 128 ],
- pName[ MAX_PLAYER_NAME ]
- ;
- GetPlayerName( playerid, pName, sizeof pName );
- format( str, sizeof str, "AFK >> {00FFFF}%s ( %d ) {FFFFFF}is now back. Reason : {00FFFF}%s",
- pName, playerid, afkReason[ playerid ] );
- SendClientMessageToAll( -1, str );
- TogglePlayerControllable( playerid, 1 );
- SetPlayerVirtualWorld( playerid, pVirtualWorld[ playerid ] );
- return 1;
- }
- CMD:afklist( playerid, params[ ] ) {
- new
- count,
- pName[ MAX_PLAYER_NAME ],
- str[ 128 ]
- ;
- SendClientMessage( playerid, -1, "-------------------------------------" );
- for ( new i, j = GetMaxPlayers( ); i < j; ++ i ) {
- if ( i == INVALID_PLAYER_ID )
- continue;
- if ( !gPlayerAFK{ i } )
- continue;
- ++ count;
- GetPlayerName( i, pName, sizeof pName );
- format( str, 128, "%d) %s ( %d ) - {00FFFF}Reason : %s",
- count, pName[ i ], i, afkReason[ i ] );
- SendClientMessage( playerid, -1, str );
- }
- if ( !count )
- SendClientMessage( playerid, -1, "No players AFK." );
- SendClientMessage( playerid, -1, "-------------------------------------" );
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement