Zcmd command processor sscanf
new
bool: IsPlayerMuted[ MAX_PLAYERS ],
Mute_Timer[ MAX_PLAYERS ]
;
public OnPlayerText( playerid, text[ ] )
{
if( IsPlayerMuted[ playerid ] ) return 0; // Returning 0 will stop the text from being sent.
return 1;
}
CMD:mute( playerid, params[ ] )
{
new
id,
time,
reason[ 64 ]
;
if( sscanf( params, "ris[64]", id, time, reason ) ) return SendClientMessage( playerid, -1, "Usage: /mute [playerid][time/in secounds][reason]" );
if( id == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "Offline player" );
if( time < 0 ) return SendClientMessage( playerid, -1, "Time should be equal or greater to 1 seconds" );
IsPlayerMuted[ id ] = true;
Mute_Timer[ id ] = SetTimerEx( "OnPlayerUnmute", time * 1000, false, "i", id );
new
name_[ MAX_PLAYER_NAME ],
msg[ 128 ]
;
GetPlayerName( id, name_, MAX_PLAYER_NAME );
format( msg, sizeof( msg ), "%s has been muted by an Administrator for %d seconds. Reason: %s!", name_, time, reason );
SendClientMessageToAll( 0xFF0000FF, msg );
return 1;
}
forward OnPlayerUnmute( playerid );
public OnPlayerUnmute( playerid )
{
if( IsPlayerMuted[ playerid ] )
{
IsPlayerMuted[ playerid ] = false;
new
name_[ MAX_PLAYER_NAME ],
msg[ 128 ]
;
GetPlayerName( playerid, name_, MAX_PLAYER_NAME );
format( msg, sizeof( msg ), "%s has been unmuted because their time has passed!", name_ );
SendClientMessageToAll( 0xFF0000FF, msg );
}
}
That should work:
pawn Код:
|