stock MutePlayer(playerid, iGivedBy, iTime, szReason[]) { if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "Този играч не е в сървъра!"); UTS_MuteTime[playerid] = gettime() + 60 * iTime; format(szReasonMute[playerid], 32, szReason); new szName[MAX_PLAYER_NAME], szString[168]; new targetid; new TargetName[MAX_PLAYER_NAME]; GetPlayerName(targetid, TargetName, sizeof(TargetName)); GetPlayerName(iGivedBy, szName, MAX_PLAYER_NAME); format(szString, sizeof(szString), "{FF1E00}%s е заглушен от администратор %s за %d минута/и. [Причина: %s]", TargetName, szName, iTime, szReason); SendClientMessageToAll(-1, szString); return 1; }
#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;
}
PHP код:
|
#include a_samp
#include sscanf2
#include zcmd
#include foreach
enum playerinfo
{
Name[MAX_PLAYER_NAME + 1],
bool: IsMuted,
MuteTime,
MuteWarnings,
MuteTimer
}
new Player[MAX_PLAYERS][playerinfo];
main()
{
return 1;
}
public OnPlayerConnect(playerid)
{
GetPlayerName(playerid, Player[playerid][Name], MAX_PLAYER_NAME + 1);
}
public OnPlayerText(playerid, text[])
{
if(Player[playerid][IsMuted] == true)
{
SendClientMessage(playerid, -1, "You are muted.");
Player[playerid][MuteWarnings]++;
if(Player[playerid][MuteWarnings] >= 5)
{
//send a message to who you like to say the player is getting kicked because of trying to spam despite he is muted
// Add a SetTimerEx, and put "Kick(playerid);" in the public function you call with this timer so the player who gets kicked will read the kick reason. If you kick him on this line he will not read that
}
return 0;
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(Player[playerid][MuteTime] > 0)
{
new string[128];
format(string, sizeof string, "%s left with a mute time of %d seconds", Player[playerid][Name], Player[playerid][MuteTime] / 1000);
SendClientMessageToAll(-1, string);
}
ResetPlayerVariables(playerid);
return 1;
}
ResetPlayerVariables(playerid)
{
Player[playerid][IsMuted] = false;
Player[playerid][MuteTime] = 0;
Player[playerid][MuteWarnings] = 0;
}
CMD:mute(playerid, params[])
{
// Admin level Check here
new id, reason[32], amount, string[128];
if(sscanf(params, "ds[32]d", id, reason, amount))return SendClientMessage(playerid, -1, "Usage: /mute [playerid][reason][time in seconds]");
if(!IsPlayerConnected(id))return SendClientMessage(playerid, -1, "Player not connected");
if(Player[id][IsMuted]== true)return SendClientMessage(playerid, -1, "Player is already muted.");
if(amount < 0)return SendClientMessage(playerid, -1, "Muting time should be higher than 0 seconds");
Player[id][IsMuted] = true;
amount =* 1000; // amount = amount * 1000. We will need milliseconds
format(string, sizeof string, "You muted %s. Reason: %s. Time left: %d seconds", Player[id][Name], reason, amount/1000);
SendClientMessage(playerid, -1, string);
format(string, sizeof string, "You are now muted Reason: %s. Time left: %d seconds", reason, amount/1000);
SendClientMessage(id, -1, string);
Player[id][MuteTimer] = SetTimerEx("UnmutePlayer", amount, false, "i", id);
return 1;
}
CMD:unmute(playerid, params[])
{
// Admin level Check here
new id, string[128];
if(sscanf(params, "d", id))return SendClientMessage(playerid, -1, "Usage: /unmute [playerid]");
if(!IsPlayerConnected(id))return SendClientMessage(playerid, -1, "Player not connected");
if(Player[id][IsMuted]== false)return SendClientMessage(playerid, -1, "Player is not muted.");
Player[id][IsMuted] = false;
format(string, sizeof string, "You unmuted %s", Player[id][Name]);
SendClientMessage(playerid, -1, string);
SendClientMessage(id, -1, "You are now unmuted.");
KillTimer(Player[id][MuteTimer]);
return 1;
}
forward UnmutePlayer(playerid);
public UnmutePlayer(playerid)
{
Player[playerid][IsMuted] = false;
Player[playerid][MuteWarnings] = 0;
Player[playerid][MuteTime] = 0;
return 1;
}
stock MutePlayer(playerid, duration) {
gPlayerMuteTime[playerid] = gettime() + duration;
}
public OnPlayerText(playerid, text[]) {
if(gPlayerMuteTime[playerid] > gettime()) {
SendClientMessage(playerid, 0xFF0000FF, "You are muted.");
return 0;
}
return 1;
}