30.09.2013, 20:09
I wrote an example in a thread few hours ago and like I said there - it's always better to try avoiding timers as much as you can.
That should work.
That should work.
pawn Код:
new
Allow_Talk[ MAX_PLAYERS ]
;
public OnPlayerConnect( playerid )
{
Allow_Talk[ playerid ] = -1;
return 1;
}
CMD:newbie( playerid, params[ ] )
{
if( IsPlayerAdmin( playerid ) ) return 1; // non-admins only - change to your variable if you want!
if( isnull( params ) ) return SendClientMessage( playerid, -1, "Usage: /newbie <message>" );
if( Allow_Talk[ playerid ] == -1 || ( Allow_Talk[ playerid ] != -1 && ( gettime( ) - Allow_Talk[ playerid ] ) > 30 ) )
{
// do your code here and.. send it to all/specific players, depending on your code
Allow_Talk[ playerid ] = gettime( );
}
else if( Allow_Talk[ playerid ] != -1 && ( gettime( ) - Allow_Talk[ playerid ] ) <= 30 )
{
new
error_msg[ 70 ]
;
format( error_msg, sizeof( error_msg ), "Newbie chat: You have to wait %d seconds before using the chat again!", gettime( ) - Allow_Talk[ playerid ] );
SendClientMessage( playerid, -1, error_msg );
}
return 1;
}