06.12.2012, 21:27
I recommend switching to ZCMD + SScanF2 for 100 times easier commands.
Here's how the code would look:
And here's the timer function:
Here's how the code would look:
pawn Code:
CMD:mute(playerid, params[])
{
new
cmdid,
reason[80],
minutes,
string[128];
if(PlayerInfo[playerid][AdminLevel] < 1)
return 0;
if(sscanf(params, "uis[80]", cmdid, minutes, reason))
return SendClientMessage(playerid,0xFFFF0000,"Usage: /mute [id/name] [time] [reason]");
if(PlayerInfo[cmdid][AdminLevel] > PlayerInfo[playerid][AdminLevel])
return SendClientMessage(playerid,COLOR_ORED,"You cant use this command against a higher level admin!");
if(cmdid == playerid)
return SendClientMessage(playerid,COLOR_ORED,"You cant mute yourself!");
if(!IsPlayerConnected(cmdid) || cmdid == INVALID_PLAYER_ID)
return SendClientMessage(playerid,COLOR_ORED,"Player not found!");
new oname[MAX_PLAYER_NAME];
GetPlayerName(cmdid, oname, sizeof(oname));
if(time == 0) //permanent mute
{
format(string, sizeof(string), "~ %s has been muted. Reason: '%s' ", oname, minutes, reason);
muted[cmdid] = 1;
}
else
{
format(string, sizeof(string), "~ %s has been muted for %i minutes. Reason: '%s' ", oname, minutes, reason);
muted[cmdid] = 1;
SetTimerEx("unmuteTimer", 60*1000*minutes, false, "i", cmdid);
}
SendClientMessageToAll(COLOR_YELLOW, string);
print(string);
return 1;
}
pawn Code:
forward muteTimer(playerid);
public unmuteTimer(playerid)
{
muted[playerid] = 0;
return SendClientMessage(playerid,0x00FF0000,"You're no longer muted!");
}