Advertisement
ANDR3X

wAntiCheat v1.0

Mar 30th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.13 KB | None | 0 0
  1. #if !defined isnull
  2.     #define isnull(%1) \
  3.                 ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
  4. #endif
  5.  
  6. stock GivePlayerWeaponEx(playerid,weaponid,ammo) {
  7.     new str[32];
  8.     format(str,sizeof(str),"Weapon%d",weaponid);
  9.     SetPVarInt(playerid,str,weaponid);
  10.     return GivePlayerWeapon(playerid,weaponid,ammo);
  11. }
  12.  
  13. #if defined _ALS_GivePlayerWeapon
  14.     #undef GivePlayerWeapon
  15. #else
  16.     #define _ALS_GivePlayerWeapon
  17. #endif
  18. #define GivePlayerWeapon GivePlayerWeaponEx
  19.  
  20. stock ResetPlayerWeaponsEx(playerid) {
  21.     resetWeaponAntiCheat(playerid);
  22.     return ResetPlayerWeapons(playerid);
  23. }
  24.  
  25. #if defined _ALS_ResetPlayerWeapons
  26.     #undef ResetPlayerWeapons
  27. #else
  28.     #define _ALS_ResetPlayerWeapons
  29. #endif
  30. #define ResetPlayerWeapons ResetPlayerWeaponsEx
  31.  
  32. forward OnWeaponAntiCheat(playerid, reason[]);
  33.  
  34. public OnWeaponAntiCheat(playerid, reason[]) {
  35.     new str[32],weaponname[32];
  36.     for(new i=0; i<=MAX_PLAYERS; i++) {
  37.         if(IsPlayerConnected(i) && GetPlayerState(playerid) != PLAYER_STATE_NONE) {
  38.             new weaponid = GetPlayerWeapon(playerid);
  39.             format(str,sizeof(str),"Weapon%d",weaponid);
  40.             if(GetPVarInt(playerid,str) != weaponid) {
  41.                 GetWeaponName(weaponid,weaponname,sizeof(weaponname));
  42.             }
  43.         }
  44.     }
  45.     if(!isnull(weaponname)) return CallRemoteFunction("WAC_OnWeaponAntiCheat","ds",playerid,weaponname);
  46.     else return 1;
  47. }
  48.  
  49. #if defined _ALS_OnWeaponAntiCheat
  50.         #undef OnWeaponAntiCheat
  51. #else
  52.         #define _ALS_OnWeaponAntiCheat
  53. #endif
  54. #define OnWeaponAntiCheat WAC_OnWeaponAntiCheat
  55. forward WAC_OnWeaponAntiCheat(playerid, reason[]);
  56.  
  57. public OnPlayerDeath(playerid, killerid, reason) {
  58.     resetWeaponAntiCheat(playerid);
  59.     return CallLocalFunction("WAC_OnPlayerDeath","ddd",playerid,killerid,reason);
  60. }
  61.  
  62. #if defined _ALS_OnPlayerDeath
  63.         #undef OnPlayerDeath
  64. #else
  65.         #define _ALS_OnPlayerDeath
  66. #endif
  67. #define OnPlayerDeath WAC_OnPlayerDeath
  68. forward WAC_OnPlayerDeath(playerid, killerid, reason);
  69.  
  70. stock resetWeaponAntiCheat(playerid) {
  71.     new str[32];
  72.     for(new i=1; i<=46; i++)  {
  73.         format(str,sizeof(str),"Weapon%d",i);
  74.         if(!GetPVarInt(playerid,str)) continue;
  75.         SetPVarInt(playerid,str,0);
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement