Ich habe mal den Code herausgeschnitten:
enum cheatinfo
{
bool:active, //Antticheat für Spieler aktiv oder nicht
pLag,
pCheat,
bool:GetMoney, //Money
pMoney,
bool:GetHealth, //Leben
Float:pHealth,
bool:GetArmour, //Rüstung
Float:pArmour,
bool:GetWeapon, //Waffen
pWeapon[13],
pAmmo[13],
}
new pAntiCheat[MAX_PLAYERS][cheatinfo];
forward CheatCheck();
forward Lag(playerid);
forward Cheat(playerid, cGrund[]);
forward ResetAntiCheat(playerid);
forward SetAntiCheat(playerid);
public OnGameModeInit()
{
SetTimer("CheatCheck", 773, 1);
}
public Lag(playerid)
{
pAntiCheat[playerid][pLag]++;
if(pAntiCheat[playerid][pLag] >= Max_Lag)
{
new str[125];
format(str,sizeof(str),"[Server] %s wurde vom Server gekickt, Grund: Lag", pName[playerid]);
SendClientMessageToAll(0xFF6347FF,str);
SendClientMessage(playerid, COLOR_ERROR,"Sie wurden vom Server gekickt, Grund: Lag");
Kick(playerid);
}
return 1;
}
public Cheat(playerid, cGrund[])
{
pAntiCheat[playerid][pCheat]++;
SendCheatWarn(playerid, cGrund);
if(pAntiCheat[playerid][pCheat] >= Max_Cheat)
{
new str[125];
format(str,sizeof(str),"[Server] %s wurde vom System gebannt, Grund: %s", pName[playerid], cGrund);
SendClientMessageToAll(0xFF6347FF,str);
Spieler[playerid][ban] = true;
format(Spieler[playerid][bangrund],100,"%s",cGrund);
Kick(playerid);
}
return 1;
}
public ResetAntiCheat(playerid)
{
pAntiCheat[playerid][active] = false;
pAntiCheat[playerid][pLag] = 0;
pAntiCheat[playerid][pCheat] = 0;
pAntiCheat[playerid][GetMoney] = false;
pAntiCheat[playerid][pMoney] = 0;
pAntiCheat[playerid][GetHealth] = false;
pAntiCheat[playerid][pHealth] = 0.0;
pAntiCheat[playerid][GetArmour] = false;
pAntiCheat[playerid][pArmour] = 0.0;
pAntiCheat[playerid][GetWeapon] = false;
for(new w = 0; w < 13; w++)
{
pAntiCheat[playerid][pWeapon][w] = 0;
pAntiCheat[playerid][pAmmo][w] = 0;
}
return 1;
}
public SetAntiCheat(playerid)
{
pAntiCheat[playerid][GetHealth] = true;
pAntiCheat[playerid][GetArmour] = true;
pAntiCheat[playerid][GetMoney] = true;
pAntiCheat[playerid][GetWeapon] = true;
pAntiCheat[playerid][pLag] = 0;
pAntiCheat[playerid][pCheat] = 0;
pAntiCheat[playerid][pHealth] = 250.0;
pAntiCheat[playerid][pArmour] = 250.0;
pAntiCheat[playerid][pMoney] = GetPlayerMoney(playerid);
for(new w = 0; w < 13; w++)
{
new weap[2];
GetPlayerWeaponData(playerid, w, weap[0], weap[1]);
pAntiCheat[playerid][pWeapon][w] = weap[0];
pAntiCheat[playerid][pAmmo][w] = weap[1];
}
pAntiCheat[playerid][active] = true;
}
public OnPlayerDisconnect(playerid, reason)
{
ResetAntiCheat(playerid);
return 1;
}
public OnPlayerSpawn(playerid)
{
SetAntiCheat(playerid);
return 1;
}
public CheatCheck()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i) || !LoggedIn[i] || IsPlayerNPC(i)) continue;
if(!pAntiCheat[i][active]) continue;
//Anti-Money:
if(pAntiCheat[i][pMoney] > GetPlayerMoney(i)) pAntiCheat[i][pMoney] = GetPlayerMoney(i);
if(GetPlayerMoney(i) > pAntiCheat[i][pMoney])
{
if(pAntiCheat[i][GetMoney])
{
pAntiCheat[i][pMoney] = GetPlayerMoney(i);
Lag(i);
}
else
{
ResetPlayerMoney(i);
GivePlayerMoney(i, pAntiCheat[i][pMoney]);
Cheat(i, "Geld-Cheat");
}
}
else pAntiCheat[i][pMoney] = GetPlayerMoney(i);
pAntiCheat[i][GetMoney] = false;
//Anti-Leben:
if(!aDuty[i]) //falls man Admin onDuty ist
{
new Float:cHP;
GetPlayerHealth(i, cHP);
if(cHP > 200.0) //man kann maximal 200.0 haben vom script aus
{
pAntiCheat[i][pCheat] = Max_Cheat-1;
Cheat(i, "Leben-Cheat");
continue;
}
else if(cHP > pAntiCheat[i][pHealth])
{
if(pAntiCheat[i][GetHealth])
{
pAntiCheat[i][pHealth] = cHP;
Lag(i);
}
else
{
SetPlayerHealth(i, pAntiCheat[i][pHealth]);
Cheat(i, "Leben-Cheat");
}
}
else pAntiCheat[i][pHealth] = cHP;
}
pAntiCheat[i][GetHealth] = false;
//Anti-Armour:
new Float:cAHP;
GetPlayerArmour(i, cAHP);
if(cAHP > 200.0)
{
pAntiCheat[i][pCheat] = Max_Cheat-1;
Cheat(i, "Armour-Cheat");
continue;
}
else if(cAHP > pAntiCheat[i][pArmour])
{
if(pAntiCheat[i][GetArmour])
{
pAntiCheat[i][pArmour] = cAHP;
Lag(i);
}
else
{
SetPlayerArmour(i, pAntiCheat[i][pArmour]);
Cheat(i, "Armour-Cheat");
}
}
else pAntiCheat[i][pArmour] = cAHP;
pAntiCheat[i][GetArmour] = false;
//Anti Weapon:
for(new w = 0; w < 13; w++)
{
new pcweap[2];
GetPlayerWeaponData(i, w, pcweap[0], pcweap[1]);
if(pcweap[0] <= 0 || pcweap[1] <= 0)
{
pAntiCheat[i][pWeapon][w] = 0;
pAntiCheat[i][pAmmo][w] = 0;
continue;
}
if(pcweap[0] == 46)
{
pAntiCheat[i][pWeapon][w] = 46;
pAntiCheat[i][pAmmo][w] = 1;
continue;
}
if(pcweap[0] != pAntiCheat[i][pWeapon][w])
{
if(pAntiCheat[i][GetWeapon])
{
pAntiCheat[i][pWeapon][w] = pcweap[0];
pAntiCheat[i][pAmmo][w] = pcweap[1];
Lag(i);
}
else
{
pAntiCheat[i][GetWeapon] = true;
DeletePlayerWeapon(i,pcweap[0]);
Cheat(i, "Waffencheat");
}
}
else
{
if(pcweap[1] < pAntiCheat[i][pAmmo][w]) pAntiCheat[i][pAmmo][w] = pcweap[1];
else if(pcweap[1] > pAntiCheat[i][pAmmo][w])
{
if(pAntiCheat[i][GetWeapon])
{
pAntiCheat[i][pWeapon][w] = pcweap[0];
pAntiCheat[i][pAmmo][w] = pcweap[1];
Lag(i);
}
else
{
pAntiCheat[i][GetWeapon] = true;
DeletePlayerWeapon(i,pcweap[0]);
Cheat(i, "Waffencheat");
}
}
}
}
pAntiCheat[i][GetWeapon] = false;
}
}
stock j_GivePlayerWeapon(playerid, weaponid, ammo)
{
pAntiCheat[playerid][GetWeapon] = true;
GivePlayerWeapon(playerid, weaponid, ammo);
pAntiCheat[playerid][pWeapon][GetSlot(weaponid)] = weaponid;
pAntiCheat[playerid][pAmmo][GetSlot(weaponid)] += ammo;
return 1;
}
stock j_ResetPlayerWeapons(playerid)
{
pAntiCheat[playerid][GetWeapon] = true;
ResetPlayerWeapons(playerid);
for(new i = 0; i < 13; i++)
{
pAntiCheat[playerid][pWeapon][i] = 0;
pAntiCheat[playerid][pAmmo][i] = 0;
}
return 1;
}
stock GetSlot(weaponx)
{
new slot;
if(weaponx == 0 || weaponx == 1) slot = 0;
else if(weaponx > 8 && weaponx < 10) slot = 1;
else if(weaponx > 9 && weaponx < 16) slot = 10;
else if(weaponx > 15 && weaponx < 20) slot = 8;
else if(weaponx > 21 && weaponx < 25) slot = 2;
else if(weaponx > 24 && weaponx < 28) slot = 3;
else if(weaponx == 28 || weaponx == 29 || weaponx == 32) slot = 4;
else if(weaponx == 30 || weaponx == 31) slot = 5;
else if(weaponx == 33 || weaponx == 34) slot = 6;
else if(weaponx > 34 || weaponx < 39) slot = 7;
else slot = -1;
return slot;
}
stock j_SetPlayerHealth(playerid, Float:hp)
{
pAntiCheat[playerid][GetHealth] = true;
SetPlayerHealth(playerid, hp);
pAntiCheat[playerid][pHealth] = hp;
return 1;
}
stock j_SetPlayerArmour(playerid, Float:ahp)
{
pAntiCheat[playerid][GetArmour] = true;
SetPlayerArmour(playerid, ahp);
pAntiCheat[playerid][pArmour] = ahp;
return 1;
}
stock j_GivePlayerMoney(playerid, amount, bool:mal100 = true)
{
pAntiCheat[playerid][GetMoney] = true;
if(mal100)
{
GivePlayerMoney(playerid,amount*100);
pAntiCheat[playerid][pMoney]+=amount*100;
}
else
{
GivePlayerMoney(playerid,amount);
pAntiCheat[playerid][pMoney]+=amount;
}
return 1;
}