public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
if(GetTeam{playerid} == CLASS_CIV && IsPlayerHoldingAGun(playerid) == 1)
{
foreach(Player, i)
{
shotsfired[playerid] += 2;
if(shotsfired[playerid] == 1 && shotsfired[playerid] != 1)
{
new current_zone, string[150];
current_zone = Player_Zone[playerid];
SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 3);
format(string, sizeof(string), "Crime in progress! %s (%d) has assaulted %s (%d) with a deadly weapon - Location: %s", GetName(playerid), playerid, GetName(damagedid), damagedid, ZoneNames[current_zone][zone_name]);
CopRadio(LIGHTBLUE, string);
format(fstr, sizeof(fstr), "Committed A Crime: Assault With A Deadly Weapon - Wanted Level %d - Ticketable", GetPlayerWantedLevel(playerid));
SendClientMessage(playerid, YELLOW, string);
shotsfired[playerid] = 1;
shotsfired{playerid} = SetTimerEx("shotsfired", 100000, true, "d", i);
}
else
{
new current_zone, string[150];
current_zone = Player_Zone[playerid];
SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 6);
format(string, sizeof(string), "Crime in progress! %s (%d) has assaulted %s (%d) with a deadly weapon - Location: %s", GetName(playerid), playerid, GetName(damagedid), damagedid, ZoneNames[current_zone][zone_name]);
CopRadio(LIGHTBLUE, string);
format(fstr, sizeof(fstr), "Committed A Crime: Assault With A Deadly Weapon - Wanted Level %d - Arrestable", GetPlayerWantedLevel(playerid));
SendClientMessage(playerid, RED, fstr);
shotsfired[playerid] = 1;
shotsfired{playerid} = SetTimerEx("shotsfired", 100000, true, "d", i);
}
}
}
return 1;
}
new pAntiSpam[MAX_PLAYERS]; // Don't call it this..
public SomeEvent(playerid)
{
if(gettime()-pAntiSpam[playerid] > 10) // It's been at least 10 seconds since we sent the last message
{
SendClientMessage(..);
pAntiSpam[playerid] = gettime();
}
return 1;
}
Why do you have a foreach loop when you don't do anything with it..?
The best way to make an anti-spam (IMO) is this (without ANY timers): pawn Код:
|