11.05.2011, 12:56
(
Последний раз редактировалось ylleron; 11.05.2011 в 19:04.
)
Anticheat for Unlimited Ammo
Welcome. I want to try create something special. And that it is this script! Unlimited function for Ammo by Timer. It works something like this:1. Check player ammo -> save to var
2. Start timer about 500 ms
3. Check new palyer ammo and match with old
4. REASON: if they are match -> Send message to admin about potentionaly hacker/cheater but isn't any admin on server, script automatically kick cheater!
I tested this on my server and ever found my cheat!
If player have unlimited ammo -> Freezed!
Код:
new oldammo, newammo; #define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) // If player is on foot (you can make your own anticheat for player in veh) { if(PRESSED(KEY_FIRE)) { if (HavePlayerWeapon(playerid)) // If player have weapon { oldammo = GetPlayerAmmo(playerid); // Save variable SetTimerEx("CheckAmmo", 500, false, "i", playerid); } return false; } } return true; }
Код:
public CheckAmmo(playerid) { newammo = GetPlayerAmmo(playerid); if (oldammo == newammo){ SendWarningMessage(playerid, "Unlimited Ammo"); } return true; }
Код:
stock SendWarningMessage(playerid, thread[]) { if (AdminsOnline() > 0) { new str[200]; for (new i;i<=MAX_PLAYERS_EX;i++) { if (IsPlayerConnected(i) && IsPlayerAdmin(i)) { format(str, sizeof(str),"[ Anticheat] Potentionaly cheater [Nick: %s [ID: %d]] [%s]", GetName(playerid), playerid, thread); SendClientMessage(i, 0xFF0000AA, str); } } } else { format(str, sizeof(str),"[ Anticheat] %s has been automatically kicked for %s", GetName(playerid), thread); SendClientMessageToAll(0xFF0000AA, str); Kick(playerid); } return true; }
Код:
stock HavePlayerWeapon(playerid) { switch(GetPlayerWeapon(playerid)) { case 16..18,22..39,41,42: return true; default: return false; } }
Код:
AdminsOnline() { new p; for(new i=0;i<=MAX_PLAYERS_EX;i++) if(IsPlayerConnected(i)) if(IsPlayerAdmin(i)) p++; return p; }