YashasSamaga

Untitled

Oct 1st, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. #include <a_samp>
  2. #include <izcmd>
  3.  
  4. #define INVALID_WEAPON 0
  5. #define MAX_WEAPON_SLOTS 13
  6. #define MAX_WEAPONS 47
  7. /////////////////////////////////////////////////////////////////////////////////
  8. static pWeaponData[MAX_PLAYERS][MAX_WEAPON_SLOTS];
  9. static pAmmoData[MAX_PLAYERS][MAX_WEAPON_SLOTS];
  10. static pAmmoWarns[MAX_PLAYERS];
  11.  
  12. static const WeaponSlot[MAX_WEAPONS] =
  13. {
  14. 0,0,1,1,1,1,1,1,1,1,10,10,10,10,10,10,8,8,8,-1,-1,-1,2,2,2,3,3,3,4,4,5,5,4,6,6,7,7,7,7,8,12,9,9,9,11,11,11
  15. };
  16. /////////////////////////////////////////////////////////////////////////////////
  17. stock ac_SetPlayerAmmo(playerid,weaponslot,ammo)
  18. {
  19. pAmmoData[playerid][weaponslot] = ammo;
  20. return SetPlayerAmmo(playerid,weaponslot,ammo);
  21. }
  22.  
  23. #if defined _ALS_SetPlayerAmmo
  24. #undef SetPlayerAmmo
  25. #else
  26. #define _ALS_SetPlayerAmmo
  27. #endif
  28. #define SetPlayerAmmo ac_SetPlayerAmmo
  29.  
  30. stock ac_GivePlayerWeapon(playerid,weaponid,ammo)
  31. {
  32. pWeaponData[playerid][WeaponSlot[weaponid]] = weaponid;
  33. pAmmoData[playerid][WeaponSlot[weaponid]] = GetPlayerAmmo(playerid) + ammo;
  34. return GivePlayerWeapon(playerid,weaponid,ammo);
  35. }
  36.  
  37. #if defined _ALS_GivePlayerWeapon
  38. #undef GivePlayerWeapon
  39. #else
  40. #define _ALS_GivePlayerWeapon
  41. #endif
  42.  
  43. #define GivePlayerWeapon ac_GivePlayerWeapon
  44.  
  45. stock ac_ResetPlayerWeapons(playerid)
  46. {
  47. for(new i = 0; i < MAX_WEAPON_SLOTS;i++)
  48. {
  49. pWeaponData[playerid][i] = INVALID_WEAPON;
  50. pAmmoData[playerid][i] = 0;
  51. }
  52. return ResetPlayerWeapons(playerid);
  53. }
  54.  
  55. #if defined _ALS_ResetPlayerWeapons
  56. #undef ResetPlayerWeapons
  57. #else
  58. #define _ALS_ResetPlayerWeapons
  59. #endif
  60.  
  61. #define ResetPlayerWeapons ac_ResetPlayerWeapons
  62. /////////////////////////////////////////////////////////////////////////////////
  63. forward WeaponCheck();
  64. public WeaponCheck()
  65. {
  66. static wid;
  67. for(new playerid = 0; playerid <= GetMaxPlayers(); playerid++)
  68. {
  69. wid = GetPlayerWeapon(playerid);
  70. if(wid == -1) continue; //INVALID WEAPON
  71.  
  72. switch(GetPlayerState(playerid))
  73. {
  74. case PLAYER_STATE_NONE,PLAYER_STATE_WASTED,PLAYER_STATE_SPAWNED: continue;
  75. }
  76.  
  77. if(pWeaponData[playerid][WeaponSlot[wid]] != wid)
  78. {
  79. new str[144],name[24],wname[24];
  80. GetPlayerName(playerid,name,sizeof(name));
  81. GetWeaponName(wid,wname,sizeof(wname));
  82. format(str,256,"%s(%d) suspected to be using Weapon Hacks (Weapon Name:%s)",name,playerid,wname);
  83. SendClientMessageToAll(-1,str);
  84. }
  85. if(pAmmoData[playerid][WeaponSlot[wid]] < GetPlayerAmmo(playerid))
  86. {
  87. if(++pAmmoWarns[playerid] == 3)
  88. {
  89. pAmmoWarns[playerid] = 0;
  90. new str[144],name[24],wname[24];
  91. GetPlayerName(playerid,name,sizeof(name));
  92. GetWeaponName(wid,wname,sizeof(wname));
  93. format(str,256,"%s(%d) suspected to be using Ammo Hacks (Weapon Name:%s)",name,playerid,wname);
  94. SendClientMessageToAll(-1,str);
  95. }
  96. }
  97. else pAmmoWarns[playerid] = 0;
  98. pAmmoData[playerid][WeaponSlot[wid]] = GetPlayerAmmo(playerid);
  99. continue;
  100. }
  101. }
  102. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  103. {
  104. SendClientMessageToAll(-1,"Ammo Fired");
  105. pAmmoData[playerid][WeaponSlot[weaponid]]--;
  106. return 1;
  107. }
  108. /////////////////////////////////////////////////////////////////////////////////
  109. main()
  110. {
  111.  
  112. }
  113. public OnGameModeInit()
  114. {
  115. SetGameModeText("asdasdasd");
  116. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  117. SetTimer("WeaponCheck",1000,true);
  118. return 1;
  119. }
  120. public OnPlayerConnect(playerid)
  121. {
  122. pAmmoWarns[playerid] = 0;
  123. ResetPlayerWeapons(playerid);
  124. return 1;
  125. }
  126. public OnPlayerSpawn(playerid)
  127. {
  128. ResetPlayerWeapons(playerid);
  129. GivePlayerWeapon(playerid,28,100);
  130. return 1;
  131. }
Advertisement
Add Comment
Please, Sign In to add comment