22.12.2009, 22:07
Which method would be better for this anticheat and cause less lag. Please also post why you would choose OnPlayerUpdate or timer.
pawn Код:
#include <a_samp>
#include <IsPlayerLadmin>
new timer;
new bool: ADMIN[MAX_PLAYERS];
new bool: ADMIN2[MAX_PLAYERS];
new bool: ADMIN3[MAX_PLAYERS];
new bool: ADMIN4[MAX_PLAYERS];
new bool: ADMIN5[MAX_PLAYERS];
public OnFilterScriptInit()
{
timer = SetTimer("AntiCheat",5000,true);
print("Cheat Extinguisher by [SU]BP13 loaded");
return 1;
}
public OnFilterScriptExit()
{
KillTimer(timer);
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
if(IsPlayerLAdmin(playerid))
{
ADMIN[playerid] = true;
ADMIN2[playerid] = true;
ADMIN3[playerid] = true;
ADMIN4[playerid] = true;
ADMIN5[playerid] = true;
}
return 1;
}
public OnPlayerDisconnect(playerid)
{
ADMIN[playerid] = false;
ADMIN2[playerid] = false;
ADMIN3[playerid] = false;
ADMIN4[playerid] = false;
ADMIN5[playerid] = false;
return 1;
}
forward AntiCheat();
public AntiCheat()
{
new weap, ammo;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(ADMIN[i] == false)
{
GetPlayerWeaponData(i, 9, weap, ammo);
if(weap == 42)
{
new string [128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(i, pName, sizeof(pName));
format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
SendClientMessageToAll(0xFF0000FF, string);
BanEx(i, "AntiCheat - Fire Extinguisher");
}
}
if(ADMIN2[i] == false)
{
GetPlayerWeaponData(i, 10, weap, ammo);
if(weap == 15)
{
new string [128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(i, pName, sizeof(pName));
format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
SendClientMessageToAll(0xFF0000FF, string);
BanEx(i, "AntiCheat - Cane");
}
}
if(ADMIN3[i] == false)
{
GetPlayerWeaponData(i, 1, weap, ammo);
if(weap == 7)
{
new string [128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(i, pName, sizeof(pName));
format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
SendClientMessageToAll(0xFF0000FF, string);
BanEx(i, "AntiCheat - Pool Cue");
}
}
if(ADMIN4[i] == false)
{
GetPlayerWeaponData(i, 11, weap, ammo);
if(weap == 44)
{
new string [128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(i, pName, sizeof(pName));
format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
SendClientMessageToAll(0xFF0000FF, string);
BanEx(i, "AntiCheat - Nightvision");
}
}
if(ADMIN5[i] == false)
{
GetPlayerWeaponData(i, 11, weap, ammo);
if(weap == 45)
{
new string [128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(i, pName, sizeof(pName));
format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
SendClientMessageToAll(0xFF0000FF, string);
BanEx(i, "AntiCheat - Thermal Goggles");
}
}
}
return 1;
}