04.02.2011, 00:05
I have an anti-cheat timer, that does alot of things.. I've tried to implement using foreach, but my script has never had an ammount of +10 players, so I'd like to know if this code is stable.
It runs every 500 ms.
It runs every 500 ms.
pawn Код:
public AntiCheat()
{
if (ServerConfig[AntiCheatEnabled] == 0) { return 0; }
else
foreach (Player, i)
{
if (IsSpawned(i))
{
// Anti jetpack hack
if(GetPlayerSpecialAction(i) == SPECIAL_ACTION_USEJETPACK)
{
if (PlayerInfo[i][pAdminLevel] == 0)
{
new ban[128], name[40];
GetPlayerName(i,name,40);
format(ban,sizeof(ban),"AdmWarn: %s has been banned by ALLIGATOR [Reason: jetpack hacks]",i);
SendClientMessageToAll(COLOR_RED,ban);
PlayerInfo[i][pAccountLocked] = 1;
print(ban);
BanEx(i,"JETPACK HACKS");
return 1;
}
else return 1;
}
// Anti forbidden weapons
new w = GetPlayerWeapon(i);
if (w == WEAPON_MINIGUN || w == WEAPON_ROCKETLAUNCHER || w == 43 || w == 42
|| w == WEAPON_MOLTOV || w == WEAPON_HEATSEEKER || w == 45 || w == 41
|| w == WEAPON_FLAMETHROWER || w == WEAPON_SATCHEL || w == 46 || w == 9)
{
if (PlayerInfo[i][pAdminLevel] == 0 && IsSpawned(i))
{
new ban[128], name[40];
GetPlayerName(i,name,40);
format(ban,sizeof(ban),"AdmWarn: %s has been banned by ALLIGATOR [Reason: weapon hacks]",name);
SendClientMessageToAll(COLOR_RED,ban);
print(ban);
PlayerInfo[i][pAccountLocked] = 1;
BanEx(i,"WEAPON HACKS");
}
}
// Anti weapon hack
new wepon = GetPlayerWeapon(i);
if(wepon > 0 && Weapons[i][wepon] == false && IsSpawned(i))
{
RemovePlayerWeapon(i, wepon);
new kick[128], name[40];
GetPlayerName(i,name,40);
format(kick,sizeof(kick),"AdmWarn: %s has been kicked by ALLIGATOR [Reason: suspicious weapon hacks]",name);
SendClientMessageToAll(COLOR_RED,kick);
print(kick);
Kick(i);
}
// Anti money hack
if(GetPlayerMoney(i) != PlayerInfo[i][pMoney])
{
ResetPlayerMoney(i);
GivePlayerMoney(i, PlayerInfo[i][pMoney]);
}
// Anti armour hack
new Float:armour;
GetPlayerArmour(i, armour);
if (armour > 99.0 && Godmode[i] == 0)
{
new ban[128], name[40];
GetPlayerName(i,name,40);
format(ban,sizeof(ban),"AdmWarn: %s has been banned by ALLIGATOR [Reason: armour hacks]",name);
SendClientMessageToAll(COLOR_RED,ban);
print(ban);
PlayerInfo[i][pAccountLocked] = 1;
BanEx(i,"ARMOUR HACKS");
}
// Anti vehicle health hack
new Float:health, veh;
veh = GetPlayerVehicleID(i);
GetVehicleHealth(veh, health);
if(health >= 1000.00)
{
new ban[128], name[40];
GetPlayerName(i,name,40);
format(ban,sizeof(ban),"AdmWarn: %s has been banned by ALLIGATOR [Reason: vehicle health hacks]",name);
SendClientMessageToAll(COLOR_RED,ban);
print(ban);
PlayerInfo[i][pAccountLocked] = 1;
BanEx(i,"VEHICLE HEALTH");
}
}
}
return 1;
}