SkillNasr

Drop Weapon 0.1

Sep 2nd, 2015
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.26 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define MAX_DROP_AMOUNT -1 // Drop limit , -1 = all ammo will drop
  4. #define MAX_DROP_LIFETIME 30 // after half second the pickup ( dropped weapon ) will unspawn. ( disappear). You can edit it
  5.  
  6. #define WEAPON_SLOTS 13
  7. #define INVALID_PICKUP -1
  8. #define PICKUP_TYPE 19
  9.  
  10. forward DestroyPickupEx( p );
  11.  
  12. enum pickup
  13. {
  14. creation_time,
  15. weapon,
  16. ammo,
  17. timer
  18. }
  19. new pickups [ MAX_PICKUPS ][ pickup ];
  20. new weapons[] =
  21. {
  22. // -1 = you cannot drop it , you can do which one you want.
  23. -1, // no fists
  24. 331, // - Brass Knuckles
  25. 333, // Golf Club
  26. 334, // Night Stick
  27. 335, // Knife
  28. 336, // baseball bat
  29. 337, // shovel
  30. 338, // pool cue
  31. 339, // katama
  32. 341, // chainsaw
  33. 321, // dildo
  34. 322, // white dildo
  35. 323, // Medium, white vibrator
  36. 324, // smaill, silver vibrator
  37. 325, // flowers
  38. 326, // cane
  39. 342, // grendade
  40. 343, // tear gas
  41. 344, // molotov
  42. -1, // RPG rocket - we can't pick up those, do we oO
  43. -1, // Heat-Seeking Rocket
  44. -1, // Hydra rocket
  45. 346, // colt 45
  46. 347, // silencer
  47. 348, // deagle
  48. 349, // shotgun
  49. 350, // sawn-off
  50. 351, // spaz
  51. 352, // micro-uzi
  52. 353, // mp5
  53. 355, // ak47
  54. 356, // m4a1
  55. 372, // tec9
  56. 357, // country rifle
  57. 358, // sniper rifle
  58. 359, // rocket launcher
  59. 360, // heat-seeking rocket launcher
  60. 361, // flamethrower
  61. 362, // minigun
  62. 363, // sachtel charges
  63. -1, // detonator
  64. 365, // spray can
  65. 366, // fire extinguisher
  66. 367, // camera
  67. -1, // night-vision goggles
  68. -1, // heat-vision goggles
  69. 371 // parachute
  70. };
  71.  
  72. public OnFilterScriptInit( )
  73. {
  74. print("Weapon Drop v0.1");
  75. }
  76.  
  77. public OnFilterScriptExit( )
  78. {
  79. print("Weapon Drop v0.1 safety unloaded!");
  80. }
  81.  
  82.  
  83. public OnPlayerCommandText( playerid, cmdtext[] )
  84. {
  85. if( !strcmp(cmdtext,"/dropweapon", true) )
  86. {
  87. DropWeapons( playerid );
  88. ResetPlayerWeapons( playerid );
  89. return 1;
  90. }
  91. return 0;
  92. }
  93.  
  94. public OnPlayerDeath( playerid, killerid, reason )
  95. {
  96. DropWeapons( playerid );
  97. return 1;
  98. }
  99.  
  100. DropWeapons( playerid )
  101. {
  102. new Float: px, Float: py, Float: pz;
  103. new hour,minute,second;
  104. new year, month,day;
  105. gettime(hour, minute, second);
  106. getdate(year, month, day);
  107.  
  108. GetPlayerPos( playerid, px, py, pz );
  109.  
  110. new weapon_slots[WEAPON_SLOTS + 1][2];
  111. new used_weapon_slots;
  112.  
  113. for( new i = 0; i < WEAPON_SLOTS; i ++ )
  114. {
  115. GetPlayerWeaponData( playerid, i, weapon_slots[ i ][ 0 ], weapon_slots[ i ][ 1 ]);
  116. if( i == 0 && weapon_slots[ i ][ 0 ] == 0 ) weapon_slots[ i ][ 1 ] = 0; // no fist drop
  117.  
  118. if( weapon_slots[ i ][ 1 ] > 0 && weapon_slots[ i ][ 0 ] < sizeof( weapons ) && weapons[ weapon_slots[ i ][ 0 ] ] != -1 )
  119. {
  120. used_weapon_slots ++;
  121. }
  122. else
  123. {
  124. weapon_slots[ i ][ 0 ] = 0;
  125. weapon_slots[ i ][ 1 ] = 0;
  126. }
  127. }
  128. // for create pickup
  129. new used_weapon_slots2 = used_weapon_slots;
  130. for( new i = 0; i < WEAPON_SLOTS; i ++ )
  131. {
  132. if( weapon_slots[ i ][ 1 ] > 0 )
  133. {
  134. new Float:angle = 360.0 - float(used_weapon_slots--) * ( 360.0 / float(used_weapon_slots2) );
  135.  
  136. new p = CreatePickup( weapons[ weapon_slots[ i ][ 0 ] ], PICKUP_TYPE, px + floatsin(angle,degrees) * (used_weapon_slots2/2 + 1.0), py + floatcos(angle,degrees) * (used_weapon_slots2/2 + 1.0), pz );
  137. if( p == INVALID_PICKUP )
  138. {
  139. new lowest_time;
  140. new _id;
  141. for( new j = 0; j < MAX_PICKUPS; j ++ )
  142. {
  143. if( pickups[ j ][ creation_time ] < lowest_time )
  144. {
  145. lowest_time = pickups[ j ][ creation_time ];
  146. _id = j;
  147. }
  148. }
  149.  
  150. DestroyPickupEx( _id );
  151. KillTimer( pickups[ _id ][ timer ] );
  152.  
  153. p = CreatePickup( weapons[ weapon_slots[ i ][ 0 ] ], PICKUP_TYPE, px + floatsin(angle,degrees) * (used_weapon_slots2/2 + 1.0), py + floatcos(angle,degrees) * (used_weapon_slots2/2 + 1.0), pz );
  154. }
  155. pickups[ p ][ creation_time ] = mktime(hour,minute,second,day,month,year);
  156. pickups[ p ][ weapon ] = weapon_slots[ i ][ 0 ];
  157. pickups[ p ][ ammo ] = weapon_slots[ i ][ 1 ];
  158. #if MAX_DROP_AMOUNT != -1
  159. if( pickups[ p ][ ammo ] > MAX_DROP_AMOUNT )
  160. {
  161. pickups[ p ][ ammo ] = MAX_DROP_AMOUNT;
  162. }
  163. #endif
  164. pickups[ p ][ timer ] = SetTimerEx("DestroyPickupEx", MAX_DROP_LIFETIME * 1000, 0, "i", p);
  165. }
  166. }
  167. }
  168.  
  169.  
  170. mktime(hour,minute,second,day,month,year) {
  171. new timestamp;
  172. timestamp = second;
  173. timestamp += minute * 60;
  174. timestamp += hour * 3600;
  175.  
  176. new days_of_month[12];
  177. if(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
  178. days_of_month = {31,29,31,30,31,30,31,31,30,31,30,31};
  179. } else {
  180. days_of_month = {31,28,31,30,31,30,31,31,30,31,30,31};
  181. }
  182. new days_this_year = 0;
  183. days_this_year = day;
  184. if(month > 1) {
  185. for(new i=0; i<month-1;i++) {
  186. days_this_year += days_of_month[i];
  187. }
  188. }
  189. timestamp += days_this_year * 86400;
  190.  
  191. for(new j=1970;j<year;j++) {
  192. timestamp += 31536000;
  193. if(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) timestamp += 86400; //
  194. }
  195. return timestamp;
  196. }
  197.  
  198. public DestroyPickupEx( p )
  199. {
  200. DestroyPickup( p );
  201. pickups[ p ][ creation_time ] = 0;
  202. pickups[ p ][ weapon ] = 0;
  203. pickups[ p ][ ammo ] = 0;
  204. }
  205.  
  206.  
  207.  
  208.  
  209. public OnPlayerPickUpPickup( playerid, pickupid )
  210. {
  211. if( pickups[ pickupid ][ creation_time ] != 0 )
  212. {
  213. GivePlayerWeapon( playerid, pickups[ pickupid ][ weapon ], pickups[ pickupid ][ ammo ] );
  214. }
  215. return 1;
  216. }
Advertisement
Add Comment
Please, Sign In to add comment