Advertisement
Guest User

[FS] WeaponDrop

a guest
Apr 30th, 2011
2,071
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.51 KB | None | 0 0
  1. /*======================================================================================================*
  2. * This Weapon-Drop Filterscript is made by Jeffry! *
  3. * *
  4. * *
  5. * Made in April 2011. *
  6. * *
  7. * Your Rights: *
  8. * *
  9. * -You are allowed to modify this Filterscript, aslong as you DO NOT remove credits or re-upload it. *
  10. * *
  11. * -You are NOT allowed to re-upload this Filterscript. *
  12. * -You are NOT allowed to claim this as your own. *
  13. * -You are NOT allowed to remove any credits. *
  14. * *
  15. * Thank you. *
  16. * Have fun. I would be happy if you give me /credits. :D *
  17. * *
  18. *=======================================================================================================*/
  19. #include <a_samp>
  20. //===============================================================================================================================================
  21. //-------------------------Definitions that you may change---------------------------------------------------------------------------------------
  22. //-----------------------------------------------------------------------------------------------------------------------------------------------
  23. #define WEAPON_RESPAWN_TIME 30 // After this time the pickups get destroyed if not picked up.
  24. #define MONEY_BAG_MONEY 0 // -1 = Money bag ON with all player-money 0 = Money bag OFF 1+ = Money bag ON with given amount
  25. #define MONEY_BAG_MODE 0 // 1 = Money comes from the killed player 0 = Money comes from the server
  26. new ForbiddenWeapons[]= { 38, 44, 45 }; // Here you add the weapon IDs that you do not want to be created.
  27. //-----------------------------------------------------------------------------------------------------------------------------------------------
  28. //-------------------------End of the Definitions------------------------------------------------------------------------------------------------
  29. //===============================================================================================================================================
  30.  
  31. //Variables
  32. new WeaponDrop[MAX_PLAYERS][14];
  33. new WeaponData[MAX_PLAYERS][14][2];
  34. new WeaponTimer[MAX_PLAYERS];
  35. new BagMoney = MONEY_BAG_MONEY;
  36. new BagMode = MONEY_BAG_MODE;
  37.  
  38. public OnFilterScriptInit()
  39. {
  40. OnWeaponDropInit();
  41. return 1;
  42. }
  43.  
  44. public OnPlayerPickUpPickup(playerid, pickupid)
  45. {
  46. OnWeaponDropPickup(playerid, pickupid);
  47. return 1;
  48. }
  49.  
  50. public OnPlayerDeath(playerid, killerid, reason)
  51. {
  52. OnWeaponDrop(playerid);
  53. return 1;
  54. }
  55.  
  56. //=============The Functions====================================================
  57. stock OnWeaponDropInit()
  58. {
  59. for(new i=0; i<MAX_PLAYERS; i++)
  60. {
  61. for(new a=0; a<14; a++)
  62. {
  63. WeaponDrop[i][a] = -1;
  64. WeaponData[i][a][0] = -1;
  65. WeaponData[i][a][1] = -1;
  66. }
  67. WeaponTimer[i] = -1;
  68. }
  69. print("\n--------------------------------------");
  70. print("[FS] WeaponDrop v1.0 by Jeffry loaded!");
  71. print("--------------------------------------\n");
  72. return 1;
  73. }
  74.  
  75. stock OnWeaponDropPickup(playerid, pickupid)
  76. {
  77. for(new i=0; i<MAX_PLAYERS; i++)
  78. {
  79. for(new a=0; a<13; a++)
  80. {
  81. if(WeaponDrop[i][a] == pickupid)
  82. {
  83. WeaponDrop[i][a] = -1;
  84. DestroyPickup(pickupid);
  85. GivePlayerWeapon(playerid, WeaponData[i][a][0], WeaponData[i][a][1]);
  86. WeaponData[i][a][0] = -1;
  87. WeaponData[i][a][1] = -1;
  88. }
  89. }
  90. if(WeaponDrop[i][13] == pickupid)
  91. {
  92. WeaponDrop[i][13] = -1;
  93. DestroyPickup(pickupid);
  94. GivePlayerMoney(playerid, WeaponData[i][13][0]);
  95. WeaponData[i][13][0] = -1;
  96. WeaponData[i][13][1] = -1;
  97. }
  98. }
  99.  
  100. return 1;
  101. }
  102.  
  103. stock OnWeaponDrop(playerid)
  104. {
  105. RemovePickups(playerid);
  106. new Float:x, Float:y, Float:z, dropped;
  107. GetPlayerPos(playerid,x,y,z);
  108. for(new i=0; i<13; i++)
  109. {
  110. new weapon, ammo;
  111. GetPlayerWeaponData(playerid, i, weapon, ammo);
  112. if((ammo > 0 || weapon == 1) && weapon != 0)
  113. {
  114. new model = GetModel(weapon);
  115. if(model != -1)
  116. {
  117. WeaponData[playerid][i][0] = weapon;
  118. WeaponData[playerid][i][1] = ammo;
  119. dropped++;
  120. }
  121. }
  122. }
  123. if(BagMoney != 0)
  124. {
  125. if(BagMoney == -1 && GetPlayerMoney(playerid) > 0)
  126. {
  127. WeaponData[playerid][13][0] = GetPlayerMoney(playerid);
  128. if(BagMode) GivePlayerMoney(playerid, -WeaponData[playerid][13][0]);
  129. WeaponDrop[playerid][13] = CreatePickup(1550, 1, x, y, z);
  130. if(dropped <= 0) dropped=1;
  131. }
  132. if(BagMoney > 0)
  133. {
  134. WeaponData[playerid][13][0] = BagMoney;
  135. if(BagMode) GivePlayerMoney(playerid, -WeaponData[playerid][13][0]);
  136. WeaponDrop[playerid][13] = CreatePickup(1550, 1, x, y, z);
  137. if(dropped <= 0) dropped=1;
  138. }
  139. }
  140. if(dropped > 0)
  141. {
  142. new radius;
  143. if(dropped < 3) radius = 1;
  144. if(dropped < 6) radius = 2; /*If you want another radius, change it here.*/
  145. if(dropped < 9) radius = 3;
  146. if(dropped > 8) radius = 4;
  147. new Float:degree, Float:tmp;
  148. degree = 360.0 / (float(dropped));
  149. tmp = degree;
  150. if(WeaponTimer[playerid] != -1) KillTimer(WeaponTimer[playerid]);
  151. WeaponTimer[playerid] = SetTimerEx("RemovePickups", WEAPON_RESPAWN_TIME*1000, 0, "d", playerid);
  152. for(new i=0; i<13; i++)
  153. {
  154. if((WeaponData[playerid][i][1] > 0 || WeaponData[playerid][i][0] == 1) && WeaponData[playerid][i][0] > 0)
  155. {
  156. new model = GetModel(WeaponData[playerid][i][0]);
  157. if(model != -1)
  158. {
  159. WeaponDrop[playerid][i] = CreatePickup(model, 1, x+(floatsin(degree, degrees)*radius), y+(floatcos(degree, degrees)*radius), z);
  160. degree = degree + tmp;
  161. }
  162. }
  163. }
  164. }
  165. return 1;
  166. }
  167.  
  168. stock GetModel(weaponid)
  169. {
  170. for(new i=0; i<sizeof(ForbiddenWeapons); i++)
  171. {
  172. if(weaponid == ForbiddenWeapons[i])
  173. {
  174. return -1;
  175. }
  176. }
  177. switch(weaponid)
  178. {
  179. case 1: return 331;
  180. case 2: return 333;
  181. case 3: return 334;
  182. case 4: return 335;
  183. case 5: return 336;
  184. case 6: return 337;
  185. case 7: return 338;
  186. case 8: return 339;
  187. case 9: return 341;
  188. case 10: return 321;
  189. case 11: return 322;
  190. case 12: return 323;
  191. case 13: return 324;
  192. case 14: return 325;
  193. case 15: return 326;
  194. case 16: return 342;
  195. case 17: return 343;
  196. case 18: return 344;
  197. case 22: return 346;
  198. case 23: return 347;
  199. case 24: return 348;
  200. case 25: return 349;
  201. case 26: return 350;
  202. case 27: return 351;
  203. case 28: return 352;
  204. case 29: return 353;
  205. case 30: return 355;
  206. case 31: return 356;
  207. case 32: return 372;
  208. case 33: return 357;
  209. case 34: return 358;
  210. case 35: return 359;
  211. case 36: return 360;
  212. case 37: return 361;
  213. case 38: return 362;
  214. case 39: return 363;
  215. case 40: return 364;
  216. case 41: return 365;
  217. case 42: return 366;
  218. case 43: return 367;
  219. case 44: return 368;
  220. case 45: return 369;
  221. case 46: return 371;
  222. default: return -1;
  223. }
  224. return -1;
  225. }
  226.  
  227. forward RemovePickups(playerid);
  228. public RemovePickups(playerid)
  229. {
  230. if(WeaponTimer[playerid] != -1) KillTimer(WeaponTimer[playerid]);
  231. WeaponTimer[playerid] = -1;
  232. for(new a=0; a<14; a++)
  233. {
  234. if(WeaponDrop[playerid][a] != -1)
  235. {
  236. DestroyPickup(WeaponDrop[playerid][a]);
  237. WeaponDrop[playerid][a] = -1;
  238. WeaponData[playerid][a][0] = -1;
  239. WeaponData[playerid][a][1] = -1;
  240. }
  241. }
  242. return 1;
  243. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement