Advertisement
Bomber07

Drops By Bomber07

Jan 4th, 2017
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.71 KB | None | 0 0
  1. //-------------------------------------------------
  2. //
  3. // This filter script allows you to have weapon drops after death
  4. // Uses Dynamic pickups from Incognito's Streamer
  5. //
  6. // Bomber07
  7. // Incognito for Streamer Plugin
  8. //
  9. //-------------------------------------------------
  10.  
  11. #include <a_samp> //SAMP Team
  12. #include <streamer> //Incognito
  13.  
  14. //-------------------------------------------------
  15.  
  16. #define MAX_DROPS 1000//this is the maximum amount of drops our server can have, can be extended to whatever value you want
  17.  
  18. //These are just defination of pickup models, just for ease
  19. #define PICKUP_MODEL_ARMOR 1242
  20. #define PICKUP_MODEL_HEALTH 1240
  21. #define PICKUP_MODEL_CASH 1274
  22. #define PICKUP_MODEL_CASHBAG 1550
  23.  
  24. enum StaticPickupEnum//enum
  25. {
  26. E_model,
  27. E_ammount,
  28. E_pickupid,
  29. E_timer
  30. }
  31. new gStaticPickup[MAX_DROPS][StaticPickupEnum];//all the static pickup data will be saved here
  32.  
  33. //------------------------------------------------
  34.  
  35. public OnFilterScriptInit()
  36. {
  37. //we must reseting all the data of array before doing anything, otherwise noting will work according to the system!
  38. for(new i = 0; i < MAX_DROPS; i++)
  39. {
  40. gStaticPickup[i][E_model] = -1;
  41. gStaticPickup[i][E_ammount] = -1;
  42. gStaticPickup[i][E_pickupid] = -1;
  43. }
  44. print("\n--------------------------------------");
  45. print(" Drop Filterscript by Bomber07");
  46. print(" Loaded");
  47. print("--------------------------------------\n");
  48. return 1;
  49. }
  50.  
  51. //------------------------------------------------
  52.  
  53. public OnFilterScriptExit()
  54. {
  55. for(new i = 0; i < MAX_DROPS; i++)//destroy after this FS is unloaded
  56. {
  57. DestroyStaticPickup(i);
  58. }
  59. return 1;
  60. }
  61.  
  62. //------------------------------------------------
  63.  
  64. CreateStaticPickup(Float:x, Float:y, Float:z, model, ammount, interior = -1, virtualworld = -1)
  65. {
  66. for(new i = 0; i < MAX_DROPS; i++)
  67. {
  68. if(gStaticPickup[i][E_model] == -1)
  69. {
  70. gStaticPickup[i][E_model] = model;
  71. gStaticPickup[i][E_ammount] = ammount;
  72. gStaticPickup[i][E_pickupid] = CreateDynamicPickup(model, 1, x, y, z, virtualworld, interior);
  73. gStaticPickup[i][E_timer] = SetTimerEx("OnAutoPickupDestroy", 13000, true, "i", i);
  74.  
  75. return i;//return the static pickup id
  76. }
  77. }
  78. return -1;//will return -1 if no static pickup was created
  79. }
  80.  
  81. //------------------------------------------------
  82.  
  83. //destroy the pickup and reset the array index
  84. DestroyStaticPickup(pickupid)
  85. {
  86. DestroyDynamicPickup(gStaticPickup[pickupid][E_pickupid]);
  87. gStaticPickup[pickupid][E_pickupid] = -1;
  88. gStaticPickup[pickupid][E_model] = -1;
  89. gStaticPickup[pickupid][E_ammount] = -1;
  90. return true;
  91. }
  92.  
  93. //------------------------------------------------
  94.  
  95. stock IsValidStaticPickup(pickupid)
  96. {
  97. if(gStaticPickup[pickupid][E_model] == -1) return false;
  98. return true;
  99. }
  100.  
  101. //------------------------------------------------
  102.  
  103. forward OnAutoPickupDestroy(pickupid);
  104. public OnAutoPickupDestroy(pickupid)
  105. {
  106. return DestroyStaticPickup(pickupid);
  107. }
  108.  
  109. //------------------------------------------------
  110.  
  111. public OnPlayerPickUpDynamicPickup(playerid, pickupid)
  112. {
  113. for(new i = 0; i < MAX_DROPS; i++)
  114. {
  115. if(pickupid == gStaticPickup[i][E_pickupid])
  116. {
  117. switch(gStaticPickup[i][E_model])
  118. {
  119. case 331,333..341,321..326,342..355,372,356..371: GivePlayerWeapon(playerid, GetModelWeaponID(gStaticPickup[i][E_model]), gStaticPickup[i][E_ammount]);
  120.  
  121. }
  122. DestroyStaticPickup(i);
  123. }
  124. }
  125. return 1;
  126. }
  127.  
  128. //------------------------------------------------
  129.  
  130. GetModelWeaponID(weaponid)//this gives you the weapon id of the model specified; if its incorrect, then simply returns -1;
  131. {
  132. switch(weaponid)
  133. {
  134. case 331: return 1;
  135. case 333: return 2;
  136. case 334: return 3;
  137. case 335: return 4;
  138. case 336: return 5;
  139. case 337: return 6;
  140. case 338: return 7;
  141. case 339: return 8;
  142. case 341: return 9;
  143. case 321: return 10;
  144. case 322: return 11;
  145. case 323: return 12;
  146. case 324: return 13;
  147. case 325: return 14;
  148. case 326: return 15;
  149. case 342: return 16;
  150. case 343: return 17;
  151. case 344: return 18;
  152. case 346: return 22;
  153. case 347: return 23;
  154. case 348: return 24;
  155. case 349: return 25;
  156. case 350: return 26;
  157. case 351: return 27;
  158. case 352: return 28;
  159. case 353: return 29;
  160. case 355: return 30;
  161. case 356: return 31;
  162. case 372: return 32;
  163. case 357: return 33;
  164. case 358: return 34;
  165. case 359: return 35;
  166. case 360: return 36;
  167. case 361: return 37;
  168. case 362: return 38;
  169. case 363: return 39;
  170. case 364: return 40;
  171. case 365: return 41;
  172. case 366: return 42;
  173. case 367: return 43;
  174. case 368: return 44;
  175. case 369: return 45;
  176. case 371: return 46;
  177. }
  178. return -1;
  179. }
  180.  
  181. //------------------------------------------------
  182.  
  183. GetWeaponModelID(weaponid)//this return model id from weapon id, returns -1 if incorrect
  184. {
  185. switch(weaponid)
  186. {
  187. case 1: return 331;
  188. case 2: return 333;
  189. case 3: return 334;
  190. case 4: return 335;
  191. case 5: return 336;
  192. case 6: return 337;
  193. case 7: return 338;
  194. case 8: return 339;
  195. case 9: return 341;
  196. case 10: return 321;
  197. case 11: return 322;
  198. case 12: return 323;
  199. case 13: return 324;
  200. case 14: return 325;
  201. case 15: return 326;
  202. case 16: return 342;
  203. case 17: return 343;
  204. case 18: return 344;
  205. case 22: return 346;
  206. case 23: return 347;
  207. case 24: return 348;
  208. case 25: return 349;
  209. case 26: return 350;
  210. case 27: return 351;
  211. case 28: return 352;
  212. case 29: return 353;
  213. case 30: return 355;
  214. case 31: return 356;
  215. case 32: return 372;
  216. case 33: return 357;
  217. case 34: return 358;
  218. case 35: return 359;
  219. case 36: return 360;
  220. case 37: return 361;
  221. case 38: return 362;
  222. case 39: return 363;
  223. case 40: return 364;
  224. case 41: return 365;
  225. case 42: return 366;
  226. case 43: return 367;
  227. case 44: return 368;
  228. case 45: return 369;
  229. case 46: return 371;
  230. }
  231. return -1;
  232. }
  233.  
  234. //------------------------------------------------
  235.  
  236. public OnPlayerDeath(playerid, killerid, reason)
  237. {
  238. new weapon, ammo;
  239. new Float:x, Float:y, Float:z;
  240. GetPlayerPos(playerid, x, y, z);
  241. for(new i = 0; i < 13; i++)//drop all player weapons
  242. {
  243. GetPlayerWeaponData(playerid, i, weapon, ammo);
  244. switch(weapon)
  245. {
  246. case 1..37:
  247. {
  248. if(weapon != 0 && ammo != 0) CreateStaticPickup(x + random(4), y, z, GetWeaponModelID(weapon), ammo, GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid));
  249. }
  250. }
  251. }
  252. return 1;
  253. }
  254.  
  255. //------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement