Advertisement
CIBERKILLER

DropWeapons - by CIBERKILLER

Oct 1st, 2014
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.05 KB | None | 0 0
  1. //Includes
  2. #include <a_samp>
  3. //Einstellungen
  4. #define MAX_WEAPON_PICKUPS 100
  5. #define TIMER_INTERVAL 1000
  6. //Farben
  7. #define Weis -1
  8. //Enums
  9. enum Waffendaten
  10. {
  11.     PickupID,
  12.     WaffenID,
  13.     WaffenMunni,
  14. };
  15. //forwards
  16. forward createwp(_pid, _t, Float:_1, Float:_2, Float:_3, _w, _wid, _wam);
  17. //Arrays
  18. new pWeapons[MAX_WEAPON_PICKUPS][Waffendaten];
  19. //Callbacks
  20. public OnFilterScriptInit()
  21. {
  22.     for(new j, i = sizeof(pWeapons); j<i; j++)
  23.     {
  24.         if(pWeapons[j][PickupID] == 999999)continue;
  25.         pWeapons[j][PickupID] = 999999;
  26.         if(j == sizeof(pWeapons))break;
  27.     }
  28.     return 1;
  29. }
  30. public OnFilterScriptExit()
  31. {
  32.     return 1;
  33. }
  34. public OnPlayerPickUpPickup(playerid, pickupid)
  35. {
  36.     if(!GetPVarInt(playerid, "tod"))
  37.     {
  38.         new wname[50], string[256];
  39.         for(new i;i<MAX_WEAPON_PICKUPS;i++)
  40.         {
  41.             if(pickupid != pWeapons[i][PickupID])continue;
  42.             if(pWeapons[i][WaffenID] == 0)continue;
  43.             if(pWeapons[i][WaffenMunni] == 0)continue;
  44.             GetWeaponName(pWeapons[i][WaffenID], wname, 50);
  45.             format(string, sizeof(string), "Du hast die Waffe '%s' mit jeweils %i Schuss aufgehoben!", wname, pWeapons[i][WaffenMunni]),
  46.             SendClientMessage(playerid, Weis, string);
  47.             GivePlayerWeapon(playerid, pWeapons[i][WaffenID], pWeapons[i][WaffenMunni]);
  48.             pWeapons[i][WaffenID] = 0,pWeapons[i][WaffenMunni] = 0;
  49.             DestroyPickup(pWeapons[i][PickupID]); pWeapons[i][PickupID] = 999999;
  50.         }
  51.     }
  52.     return 1;
  53. }
  54. public OnPlayerDeath(playerid, killerid, reason)
  55. {
  56.     SetPVarInt(playerid, "tod", 1);
  57.     if(IsValidPickupWeapon(GetPlayerWeapon(playerid)))
  58.     {
  59.         new Float:pPos[3];
  60.         GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
  61.         SetTimerEx("createwp", TIMER_INTERVAL, false, "ddfffddd", GetWeaponPickupID(playerid), 1, pPos[0], pPos[1], pPos[2], GetPlayerVirtualWorld(playerid), GetPlayerWeapon(playerid), GetPlayerAmmo(playerid));
  62.     }
  63. }
  64. public OnPlayerSpawn(playerid)
  65. {
  66.     if(GetPVarInt(playerid, "tod")) SetPVarInt(playerid, "tod", 0);
  67. }
  68. public createwp(_pid, _t, Float:_1, Float:_2, Float:_3, _w, _wid, _wam)
  69. {
  70.     return CreateWeaponPickup(_pid, _t, Float:_1, Float:_2, Float:_3, _w, _wid, _wam);
  71. }
  72. stock CreateWeaponPickup(_objectid, _type, Float:_x, Float:_y, Float:_z, _vw, _wid, _wam)
  73. {
  74.     printf("%d, %d, %f, %f, %f, %d, %d, %d (timer)",_objectid, _type, Float:_x, Float:_y, Float:_z, _vw, _wid, _wam);
  75.     for(new o, x = MAX_WEAPON_PICKUPS; o != x; o++)
  76.     {
  77.         if(pWeapons[o][PickupID] == 999999)
  78.         {
  79.             pWeapons[o][PickupID] = CreatePickup(_objectid, _type, _x, _y, _z, _vw);
  80.             pWeapons[o][WaffenID] = _wid,pWeapons[o][WaffenMunni] = _wam;
  81.             printf("o: %d, id: %d (timer)", o, pWeapons[o][PickupID]);
  82.             return pWeapons[o][PickupID];
  83.         }
  84.     }
  85.     return 999999;
  86. }
  87. stock GetWeaponPickupID(playerid)
  88. {
  89.     new value;
  90.     switch(GetPlayerWeapon(playerid))
  91.     {
  92.         case 24: value = 348; //deagle
  93.         case 25: value = 349; //shotgun
  94.         case 26: value = 350; //doppel shotgun
  95.     }
  96.     return value;
  97. }
  98. stock IsValidPickupWeapon(_value)
  99. {
  100.     switch(_value)
  101.     {
  102.         case 24,25,26:return 1;
  103.         default: return 0;
  104.     }
  105.     return 999999;
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement