Mute command
#1

Hey guys , i want to know how to make mute command using timers i mean /mute [playerid][time/in secounds][reason]
i already tried to search on tut. but i can't find if someone can help me with timer set please i am new to scripting (4days)
Thanks.
I am using
Код:
Zcmd command processor
sscanf
Reply
#2

Bump !
Reply
#3

I think this is what you looking for
https://sampforum.blast.hk/showthread.php?tid=290311
Reply
#4

That should work:
pawn Код:
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 );
    }
}
Reply
#5

Thank you for reply , i read about timer and i try to create now i was looking for tutorail not fliterscript but thank you anyway
-Thank you very much Konstantinos.
Reply
#6

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
That should work:
pawn Код:
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 );
    }
}
Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)