Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*/////////////////////////////////////////////////////////////////////////////////
- Anti-AmmoHack:
- --------------
- * This filterscript was created by iRage (http://forum.sa-mp.com/member.php?u=135577)
- * Feel free to do whatever you want with it.
- * Version: 1.0
- *//////////////////////////////////////////////////////////////////////////////////
- #include <a_samp>
- #include <zcmd>
- #include <sscanf>
- #define COLOR_ORANGE 0xFF8000FF
- public OnFilterScriptInit()
- {
- print("\n --------------------------------------");
- print(" Anti-AmmoHack v1.0 by iRage [LOADED]");
- print(" --------------------------------------\n");
- return 1;
- }
- /*/////////////////////////////////////////////////////////////////////////////////
- Variables:
- ----------
- * iAmmo: Saves the player's weapon ammo upon shooting to re-check later on in the timer.
- * iWeaponSlot: Saves the player's weapon slot upon shooting to define where to search in the timer.
- * iCheck: Defines if the player is already being checked or not, terminating double-checks if a player double clicks when shooting to avoid false accusations.
- *//////////////////////////////////////////////////////////////////////////////////
- new iAmmo[MAX_PLAYERS], iWeaponSlot[MAX_PLAYERS], iCheck[MAX_PLAYERS];
- /*/////////////////////////////////////////////////////////////////////////////////
- Timer:
- ------
- * Gets called once a player shoots, used to check if the ammo is still the same after player started shooting or not.
- *//////////////////////////////////////////////////////////////////////////////////
- forward AmmoCheck(playerid);
- public AmmoCheck(playerid)
- {
- if(iCheck[playerid])
- {
- new NewAmmo, WeaponID, string[128];
- GetPlayerWeaponData(playerid, iWeaponSlot[playerid], WeaponID, NewAmmo);
- if(NewAmmo >= iAmmo[playerid])
- {
- GetPlayerName(playerid, string, sizeof(string));
- format(string, sizeof(string), ">> {FF6347}[CHEAT] {33CCFF}Ammo-hack detected {9ACD32}(ID: %d | Name: %s)", playerid, string);
- SendClientMessageToAll(COLOR_ORANGE, string);
- }
- iCheck[playerid] = 0;
- }
- return 1;
- }
- /*/////////////////////////////////////////////////////////////////////////////////
- OnPlayerKeyStateChange:
- -----------------------
- * The filterscript uses this callback to detect once a player starts shooting, saving his current ammo value to check if it's the same after a while.
- *//////////////////////////////////////////////////////////////////////////////////
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- new string[128], WeaponID;
- if(!iCheck[playerid] && FiniteWeapon(playerid))
- {
- if(newkeys & KEY_FIRE || newkeys & KEY_ACTION)
- {
- if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
- {
- iWeaponSlot[playerid] = GetWeaponSlot(GetPlayerWeapon(playerid));
- GetWeaponName(GetPlayerWeapon(playerid), string, sizeof(string));
- GetPlayerWeaponData(playerid, iWeaponSlot[playerid], WeaponID, iAmmo[playerid]);
- iCheck[playerid] = 1;
- SetTimerEx("AmmoCheck", 800, false, "i", playerid);
- }
- }
- }
- return 1;
- }
- /*/////////////////////////////////////////////////////////////////////////////////
- Stocks:
- -------
- * GetWeaponSlot: Used to get which slot the weapon being held by a player is stored in.
- * FiniteWeapon: Used to define which weapons can lose ammo when used, camera excluded as it's not detected 100% accurately.
- *//////////////////////////////////////////////////////////////////////////////////
- stock GetWeaponSlot(weaponid)
- {
- new slot;
- switch(weaponid)
- {
- case 0,1: slot = 0;
- case 2 .. 9: slot = 1;
- case 10 .. 15: slot = 10;
- case 16 .. 18, 39: slot = 8;
- case 22 .. 24: slot = 2;
- case 25 .. 27: slot = 3;
- case 28, 29, 32: slot = 4;
- case 30, 31: slot = 5;
- case 33, 34: slot = 6;
- case 35 .. 38: slot = 7;
- case 40: slot = 12;
- case 41 .. 43: slot = 9;
- case 44 .. 46: slot = 11;
- }
- return slot;
- }
- stock FiniteWeapon(playerid)
- {
- new status = 0;
- for(new i = 16; i<43; i++)
- {
- if(GetPlayerWeapon(playerid) == i && GetPlayerWeapon(playerid) != 43) status = 1;
- }
- return status;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement