Guest

Tenshi

By: a guest on Aug 4th, 2009  |  syntax: C++  |  size: 5.62 KB  |  hits: 423  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. #include <a_samp>
  2.  
  3. #define MAX_DROP_AMOUNT                         -1 // special drop-limits like 500 ammo are possible; -1 = all ammo is dropped
  4. #define MAX_DROP_LIFETIME                       30 // after 30 seconds the pickup gets destroyed. Note: old pickups will be destroyed anyway.
  5.  
  6. #define WEAPON_SLOTS                            13
  7. #define INVALID_PICKUP                          -1
  8. #define MAX_PICKUPS                                     90
  9. #define PICKUP_TYPE                                     19
  10.  
  11. forward DestroyPickupEx( p );
  12.  
  13. enum pickup
  14. {
  15.         creation_time,
  16.         weapon,
  17.         ammo,
  18.         timer
  19. }
  20. new pickups [ MAX_PICKUPS ][ pickup ];
  21. // Set any of those to -1 to disable dropping of that weapon
  22. new weapons[] =
  23. {
  24.         -1, // no fists
  25.         331, // - Brass Knuckles
  26.         333, // Golf Club
  27.         334, // Night Stick
  28.         335, // Knife
  29.         336, // baseball bat
  30.         337, // shovel
  31.         338, // pool cue
  32.         339, // katama
  33.         341, // chainsaw
  34.         321, // regular dildo
  35.         322, // white dildo
  36.         323, // Medium, white vibrator
  37.         324, // smaill, silver vibrator
  38.         325, // flowers
  39.         326, // cane
  40.         342, // grendade
  41.         343, // tear gas
  42.         344, // molotov
  43.         -1, // RPG rocket - we can't pick up those, do we oO
  44.         -1, // Heat-Seeking Rocket
  45.         -1, // Hydra rocket
  46.         346, // colt 45
  47.         347, // colt 45 + silencer
  48.         348, // deagle
  49.         349, // shotgun
  50.         350, // sawn-off
  51.         351, // spaz
  52.         352, // micro-uzi
  53.         353, // mp5
  54.         355, // ak47
  55.         356, // m4
  56.         372, // tec9
  57.         357, // country rifle
  58.         358, // sniper rifle
  59.         359, // rocket launcher
  60.         360, // heat-seeking rocket launcher
  61.         361, // flamethrower
  62.         362, // minigun
  63.         363, // sachtel charges
  64.         -1, // detonator
  65.         365, // spray can
  66.         366, // fire extinguisher
  67.         367, // camera
  68.         -1, // night-vision goggles
  69.         -1, // heat-vision goggles
  70.         371 // parachute
  71. };
  72.  
  73. public OnFilterScriptInit( )
  74. {
  75.         print(" ");
  76.         print("    Weapon Drop Script v1.0");
  77.         print("    by mabako - http://mabako.net/samp/");
  78.         print(" ");
  79. }
  80.  
  81. public OnFilterScriptExit( )
  82. {
  83.         print(" ");
  84.         print("    Weapon Drop Script unloaded!");
  85.         print(" ");
  86. }
  87.  
  88. /*
  89. public OnPlayerCommandText( playerid, cmdtext[] )
  90. {
  91.         if( !strcmp(cmdtext,"/drop", true) )
  92.         {
  93.             DropWeapons( playerid );
  94.             ResetPlayerWeapons( playerid );
  95.             return 1;
  96.         }
  97.         return 0;
  98. }*/
  99.  
  100. public OnPlayerDeath( playerid, killerid, reason )
  101. {
  102.         DropWeapons( playerid );
  103.         return 1;
  104. }
  105.  
  106. DropWeapons( playerid )
  107. {
  108.         new Float: px, Float: py, Float: pz;
  109.         new hour,minute,second;
  110.         new year, month,day;
  111.         gettime(hour, minute, second);
  112.         getdate(year, month, day);
  113.  
  114.         GetPlayerPos( playerid, px, py, pz );
  115.  
  116.         new weapon_slots[WEAPON_SLOTS + 1][2];
  117.         new used_weapon_slots;
  118.  
  119.         for( new i = 0; i < WEAPON_SLOTS; i ++ )
  120.         {
  121.                 GetPlayerWeaponData( playerid, i, weapon_slots[ i ][ 0 ], weapon_slots[ i ][ 1 ]);
  122.                 if( i == 0 && weapon_slots[ i ][ 0 ] == 0 ) weapon_slots[ i ][ 1 ] = 0; // no fist...
  123.  
  124.                 if( weapon_slots[ i ][ 1 ] > 0 && weapon_slots[ i ][ 0 ] < sizeof( weapons ) && weapons[ weapon_slots[ i ][ 0 ] ] != -1 )
  125.                 {
  126.                         used_weapon_slots ++;
  127.                 }
  128.                 else
  129.                 {
  130.                     weapon_slots[ i ][ 0 ] = 0;
  131.                     weapon_slots[ i ][ 1 ] = 0;
  132.                 }
  133.         }
  134.         // Create the pickups
  135.         new used_weapon_slots2 = used_weapon_slots;
  136.         for( new i = 0; i < WEAPON_SLOTS; i ++ )
  137.         {
  138.             if( weapon_slots[ i ][ 1 ] > 0 )
  139.             {
  140.                         new Float:angle = 360.0 - float(used_weapon_slots--) * ( 360.0 / float(used_weapon_slots2) );
  141.                         // see... if there's a pickup we create by any chance
  142.  
  143.                         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 );
  144.                         if( p == INVALID_PICKUP )
  145.                         {
  146.                                 new lowest_time;
  147.                                 new _id;
  148.                                 for( new j = 0; j < MAX_PICKUPS; j ++ )
  149.                                 {
  150.                                         if( pickups[ j ][ creation_time ] < lowest_time )
  151.                                         {
  152.                                             lowest_time = pickups[ j ][ creation_time ];
  153.                                             _id = j;
  154.                                         }
  155.                                 }
  156.  
  157.                                 DestroyPickupEx( _id );
  158.                                 KillTimer( pickups[ _id ][ timer ] );
  159.  
  160.                                 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 );
  161.                         }
  162.                         pickups[ p ][ creation_time ] = mktime(hour,minute,second,day,month,year);
  163.                         pickups[ p ][ weapon ] = weapon_slots[ i ][ 0 ];
  164.                         pickups[ p ][ ammo ] = weapon_slots[ i ][ 1 ];
  165.                         #if MAX_DROP_AMOUNT != -1
  166.                     if( pickups[ p ][ ammo ] > MAX_DROP_AMOUNT )
  167.                     {
  168.                         pickups[ p ][ ammo ] = MAX_DROP_AMOUNT;
  169.                     }
  170.                     #endif
  171.                         pickups[ p ][ timer ] = SetTimerEx("DestroyPickupEx", MAX_DROP_LIFETIME * 1000, 0, "i", p);
  172.                 }
  173.         }
  174. }
  175.  
  176.  
  177. // by mabako :D
  178. mktime(hour,minute,second,day,month,year) {
  179.         new timestamp;
  180.         timestamp = second;
  181.         timestamp += minute * 60;
  182.         timestamp += hour * 3600;
  183.  
  184.         new days_of_month[12];
  185.         if(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
  186.                 days_of_month = {31,29,31,30,31,30,31,31,30,31,30,31}; // Schaltjahr
  187.         } else {
  188.                 days_of_month = {31,28,31,30,31,30,31,31,30,31,30,31}; // keins
  189.         }
  190.         new days_this_year = 0;
  191.         days_this_year = day;
  192.         if(month > 1) { // No January Calculation, because its always the 0 past months
  193.                 for(new i=0; i<month-1;i++) {
  194.                         days_this_year += days_of_month[i];
  195.                 }
  196.         }
  197.         timestamp += days_this_year * 86400;
  198.  
  199.         for(new j=1970;j<year;j++) {
  200.                 timestamp += 31536000;
  201.                 if(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) timestamp += 86400; // Schaltjahr + 1 Tag
  202.         }
  203.         return timestamp;
  204. }
  205.  
  206. public DestroyPickupEx( p )
  207. {
  208.         DestroyPickup( p );
  209.         pickups[ p ][ creation_time ] = 0;
  210.         pickups[ p ][ weapon ] = 0;
  211.         pickups[ p ][ ammo ] = 0;
  212. }
  213.  
  214.  
  215.  
  216.  
  217. public OnPlayerPickUpPickup( playerid, pickupid )
  218. {
  219.         if( pickups[ pickupid ][ creation_time ] != 0 )
  220.         {
  221.                 GivePlayerWeapon( playerid, pickups[ pickupid ][ weapon ], pickups[ pickupid ][ ammo ] );
  222.         }
  223.         return 1;
  224. }