[HELP] Mute Command
#2

PHP код:
// Top of your script
new
    
g_MuteTimer[MAX_PLAYERS],
    
g_MuteCounter[MAX_PLAYERS];
// On cnnect callback
public OnPlayerConnect(playerid)
{
    
g_MuteCounter[playerid] = 0;
    
g_MuteTimer[playerid] = -1;
    return 
1;
}
// On disconnect callback
public OnPlayerDisconnect(playeridreason)
{
    if (
g_MuteTimer[playerid] != -1)
    {
        
KillTimer(g_MuteTimer[playerid]);
    }
    return 
1;
}
// Put this anywhere in your script
forward UnmutePlayer(playerid);
public 
UnmutePlayer(playerid)
{
    if (
g_MuteTimer[playerid] != -1)
    {
        if (
g_MuteCounter[playerid] <= 0)
        {
            
SendClientMessage(playerid, -1"You have been un-muted.");
            
pInfo[playerid][Muted] = 0;
            
KillTimer(g_MuteTimer[playerid]);
            
g_MuteTimer[playerid] = -1;
        }
        else
            
g_MuteCounter[playerid]--;
    }
}
CMD:mute(playeridparams[])
{
    if(
pInfo[playerid][pLevel] >= 1)
    {
        new 
idreason[50], time;
        if(
sscanf(params"uis[50]"idtimereason) return SendClientMessage(playeridyellow"Usage: /mute <Player ID> <Minutes> <Reason>");
        if(
IsPlayerConnected(id))
        {
            if(
pInfo[id][Muted] == 1) return SendClientMessage(playerid,red,"This player is already muted. see /muted");
            if(
pInfo[playerid][pLevel] < pInfo[id][pLevel]) return ShowMessage(playeridred6);
            if(!
isnull(reason))
            
format(Jstring,sizeof(Jstring),"Administrator %s has muted player '%s' | Reason: %s",GetName(playerid),GetName(id),reason);
            else 
format(Jstring,sizeof(Jstring),"Administrator %s has muted '%s'",GetName(playerid),GetName(id));
            
SendClientMessageToAll(red,Jstring);
            
pInfo[id][Muted] = 1;
            
g_MuteCounter[id] = time 60;
            
g_MuteTimer[id] = SetTimerEx("UnmutePlayer"1000true"i"id);
            
CommandToAdmins(playerid,"mute");
            return 
1;
        }
        else return 
ShowMessage(playeridred2);
    }
    else return 
ShowMessage(playeridred1);

Not tested, should work tho.
Reply


Messages In This Thread
[HELP] Mute Command - by TwiiKzz - 15.01.2016, 16:50
Re: [HELP] Mute Command - by Sjn - 15.01.2016, 17:12
Re: [HELP] Mute Command - by Crayder - 15.01.2016, 17:12
Re: [HELP] Mute Command - by TwiiKzz - 15.01.2016, 17:40

Forum Jump:


Users browsing this thread: 1 Guest(s)