15.01.2016, 17:12
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(playerid, reason)
{
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(playerid, params[])
{
if(pInfo[playerid][pLevel] >= 1)
{
new id, reason[50], time;
if(sscanf(params, "uis[50]", id, time, reason) return SendClientMessage(playerid, yellow, "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(playerid, red, 6);
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", 1000, true, "i", id);
CommandToAdmins(playerid,"mute");
return 1;
}
else return ShowMessage(playerid, red, 2);
}
else return ShowMessage(playerid, red, 1);
}