Advertisement
JeffryUGP

[Command] WeaponDrop FS: /dropweapon

Jun 27th, 2013
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.88 KB | None | 0 0
  1. if(!strcmp(cmdtext, "/dropweapon", true, 11))
  2. {
  3.     if((strlen(cmdtext[11]) && cmdtext[11] == ' ') || !strlen(cmdtext[11]))
  4.     {
  5.         new Float:x, Float:y, Float:z;
  6.         GetPlayerPos(playerid,x,y,z);
  7.         if(x > 4095.0 || x < -4095.0 || y > 4095.0 || y < -4095.0 || z > 4095.0 || z < -4095.0) return SendClientMessage(playerid,red,"ERROR: You can not drop any weapons here, because pickups do not show here anymore (SA-MP issue).");
  8.         new world = GetPlayerVirtualWorld(playerid);
  9.         new weapon, ammo, dropped, i = GetWeaponSlot(GetPlayerWeapon(playerid));
  10.         GetPlayerWeaponData(playerid, i, weapon, ammo);
  11.         if(weapon == 0) return SendClientMessage(playerid,red,"ERROR: You are not holding any weapon.");
  12.         new dammo = strval(cmdtext[12]);
  13.         if(strlen(cmdtext[12])) if(dammo < 1) return SendClientMessage(playerid,red,"ERROR: Invalid ammo.");
  14.         if(dammo > ammo) return SendClientMessage(playerid,red,"ERROR: You don't have that much ammo.");
  15.         if(dammo == 0) dammo = ammo;
  16.         if((ammo > 0 || weapon == 1) && weapon != 0)
  17.         {
  18.             new model = GetModel(weapon);
  19.             if(model != -1)
  20.             {
  21.                 WeaponData[playerid][i][0] = weapon;
  22.                 WeaponData[playerid][i][1] = dammo;
  23.                 WeaponData[playerid][i][2] = world;
  24.                 dropped++;
  25.             }
  26.         }
  27.         if(dropped > 0)
  28.         {
  29.             if(WeaponDrop[playerid][i] != -1)
  30.             {
  31.                 DestroyPickup(WeaponDrop[playerid][i]);
  32.                 WeaponDrop[playerid][i] = -1;
  33.             }
  34.             if(WeaponTimer[playerid] != -1) KillTimer(WeaponTimer[playerid]);
  35.             WeaponTimer[playerid] = SetTimerEx("RemovePickups", WEAPON_RESPAWN_TIME*1000, 0, "d", playerid);
  36.             if((WeaponData[playerid][i][1] > 0 || WeaponData[playerid][i][0] == 1) && WeaponData[playerid][i][0] > 0)
  37.             {
  38.                 new model = GetModel(WeaponData[playerid][i][0]);
  39.                 if(model != -1)
  40.                 {
  41.                     new Float:a;
  42.                     GetPlayerFacingAngle(playerid, a);
  43.                     PickupPos[playerid][i][0] = x+(floatsin(-a, degrees)*2);
  44.                     PickupPos[playerid][i][1] = y+(floatcos(-a, degrees)*2);
  45.                     PickupPos[playerid][i][2] = z;
  46.                     WeaponDrop[playerid][i] = CreatePickup(model, 1, PickupPos[playerid][i][0], PickupPos[playerid][i][1], PickupPos[playerid][i][2], WeaponData[playerid][i][2]);
  47.                 }
  48.             }
  49.         }
  50.         else return SendClientMessage(playerid,red,"ERROR: You can not drop this weapon.");
  51.         new u_savedweapon[13], u_savedammo[13];
  52.         for(new a=0; a<13; a++) GetPlayerWeaponData(playerid, a, u_savedweapon[a], u_savedammo[a]);
  53.         u_savedammo[i] -= dammo;
  54.         ResetPlayerWeapons(playerid);
  55.         new string[128];
  56.         format(string, 128, "[Weapon] You have successfully dropped your %s.", GetUGPWeaponName(weapon));
  57.         SendClientMessage(playerid, green, string);
  58.         for(new a=0; a<13; a++) if(u_savedammo[a]!=0) GivePlayerWeapon(playerid, u_savedweapon[a], u_savedammo[a]);
  59.         if(dammo == ammo) SetPlayerArmedWeapon(playerid,0);
  60.         else SetPlayerArmedWeapon(playerid,weapon);
  61.         return 1;
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement