PHP код:
#include <sscanf2>
#include <zcmd>
new Mute[MAX_PLAYERS];
forward MuteTime();
main {}
public OnPlayerDisconnect(playerid, reason)
{
if(Mute[playerid] >= 1)
{
new mutename[MAX_PLAYER_NAME], string[100];
GetPlayerName(playerid, mutename, sizeof(mutename));
format(string, sizeof(string), "%s just left the game with a remaining mute time of %d seconds", mutename, Mute[playerid]);
for(new i = 0; i <= MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i) && IsPlayerAdmin(i))
{
SendClientMessage(i, 0xAFAFAFFF, string);
}
}
}
Mute[playerid] = 0;
return 1;
}
OnPlayerText(playerid, text[])
{
if(Mute[playerid] >= 1)
{
SendClientMessage(playerid,-1,"{f00f00}You are muted! you can't talk!");
return 0;
}
return 1;
}
public MuteTime()
{
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i))
{
if(Mute[i] >= 1)
{
Mute[i] --;
}
}
}
return 1;
}
CMD:mute(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return 0; /
new giveplayerid, reason[50], string[120], minutes, pname1[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME];
if(sscanf(params, "uds[50]", giveplayerid, minutes, reason)) return SendClientMessage(playerid, 0xFFFFFFFF, "Correct usage: /mute [playerid/name] [time in minutes] [reason]");
if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFFFFFFFF, "Player not connected.");
GetPlayerName(playerid, pname1, sizeof(pname1));
GetPlayerName(giveplayerid, pname2, sizeof(pname2));
format(string, sizeof(string), "%s (%d) was muted for %d minutes by admin %s (%d),[REASON: %s]", pname2, giveplayerid, minutes, pname1, playerid, reason);
SendClientMessageToAll(0xFFFFFFFF, string);
SetTimerEx("MuteTime", minutes, false, "i", giveplayerid);
Mute[giveplayerid] = 1;
GameTextForPlayer(giveplayerid, "~R~MUTED!", 5000, 6);
return 1;
}
CMD:unmute(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return 0;
new giveplayerid, reason[50], string[120];
if(sscanf(params, "us[50]", giveplayerid, reason)) return SendClientMessage(playerid, 0xFFFFFFFF, "{FFFF00}Syntax: /unmute [playerid/name] [reason]");
if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFFFFFFFF, "{FFFF00}Player not connected.");
new pname1[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname1, sizeof(pname1));
GetPlayerName(giveplayerid, pname2, sizeof(pname2));
format(string, sizeof(string), "%s (%d) was unmuted by %s (%d), [REASON: %s]", pname2, giveplayerid, pname1, playerid, reason);
SendClientMessageToAll(0xFFFFFFFF, string);
Mute[giveplayerid] = 0;
GameTextForPlayer(giveplayerid, "~P~UN-MUTED!", 5000, 6);
return 1;
}