10.09.2016, 08:20
chars are only really used when you know the value is going to be between 0 and 255. So yeah, shouldn't be used for functions like gettime.
Small improvements:
Small improvements:
PHP Code:
new SpamCount[MAX_PLAYERS char], ChatSpamTime[MAX_PLAYERS];
AntiSpam(playerid)
{
new time = gettime();
if((time - ChatSpamTime[playerid]) < 5 || !ChatSpamTime[playerid])
{
ChatSpamTime[playerid] = time;
switch(++SpamCount{playerid})
{
case 3:
{
new msg[75];
SendClientMessage(playerid, 0xFFFFFFFF, "[Anti-Spam]: Warning you are one message away from being muted!");
format(msg, sizeof(msg), "[Flood Control] - %s has been warned for flooding", GetName(playerid));
ABroadCast(COLOR_ADMIN, msg, 1);
}
case 4:
{
new msg[75];
format(msg, sizeof(msg), "[Anti-Spam]: %s has been muted for 5 minutes! (Reason: Spam)", GetName(playerid));
SendClientMessageToAll(0xFFFFFFFF, msg);
SendClientMessage(playerid, COLOR_GREEN, "You have received your final warning! You are now muted");
PlayerInfo[playerid][muted] = 1;
print(msg);
SetTimerEx("AutoUnMute", AutoUnmuteTime * 60000, false, "i", playerid);
SpamCount{playerid} = 0;
return 0;
}
}
}
else
{
SpamCount{playerid} = 0;
ChatSpamTime[playerid] = time;
}
return 1;
}
public OnPlayerText(playerid, text[])
{
if(!AntiSpam(playerid)) return 0;
// Rest of OnPlayerText...
}