SA-MP Forums Archive
Mute command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Mute command (/showthread.php?tid=461230)



Mute command - SilentSoul - 01.09.2013

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



Re: Mute command - SilentSoul - 01.09.2013

Bump !


Re: Mute command - DarckWilly - 01.09.2013

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


Re: Mute command - Konstantinos - 01.09.2013

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 );
    }
}



Re: Mute command - SilentSoul - 01.09.2013

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.


Re: Mute command - Swisher - 20.01.2014

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