Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(!strcmp(cmdtext, "/dropweapon", true, 11))
- {
- if((strlen(cmdtext[11]) && cmdtext[11] == ' ') || !strlen(cmdtext[11]))
- {
- new Float:x, Float:y, Float:z;
- GetPlayerPos(playerid,x,y,z);
- 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).");
- new world = GetPlayerVirtualWorld(playerid);
- new weapon, ammo, dropped, i = GetWeaponSlot(GetPlayerWeapon(playerid));
- GetPlayerWeaponData(playerid, i, weapon, ammo);
- if(weapon == 0) return SendClientMessage(playerid,red,"ERROR: You are not holding any weapon.");
- new dammo = strval(cmdtext[12]);
- if(strlen(cmdtext[12])) if(dammo < 1) return SendClientMessage(playerid,red,"ERROR: Invalid ammo.");
- if(dammo > ammo) return SendClientMessage(playerid,red,"ERROR: You don't have that much ammo.");
- if(dammo == 0) dammo = ammo;
- if((ammo > 0 || weapon == 1) && weapon != 0)
- {
- new model = GetModel(weapon);
- if(model != -1)
- {
- WeaponData[playerid][i][0] = weapon;
- WeaponData[playerid][i][1] = dammo;
- WeaponData[playerid][i][2] = world;
- dropped++;
- }
- }
- if(dropped > 0)
- {
- if(WeaponDrop[playerid][i] != -1)
- {
- DestroyPickup(WeaponDrop[playerid][i]);
- WeaponDrop[playerid][i] = -1;
- }
- if(WeaponTimer[playerid] != -1) KillTimer(WeaponTimer[playerid]);
- WeaponTimer[playerid] = SetTimerEx("RemovePickups", WEAPON_RESPAWN_TIME*1000, 0, "d", playerid);
- if((WeaponData[playerid][i][1] > 0 || WeaponData[playerid][i][0] == 1) && WeaponData[playerid][i][0] > 0)
- {
- new model = GetModel(WeaponData[playerid][i][0]);
- if(model != -1)
- {
- new Float:a;
- GetPlayerFacingAngle(playerid, a);
- PickupPos[playerid][i][0] = x+(floatsin(-a, degrees)*2);
- PickupPos[playerid][i][1] = y+(floatcos(-a, degrees)*2);
- PickupPos[playerid][i][2] = z;
- WeaponDrop[playerid][i] = CreatePickup(model, 1, PickupPos[playerid][i][0], PickupPos[playerid][i][1], PickupPos[playerid][i][2], WeaponData[playerid][i][2]);
- }
- }
- }
- else return SendClientMessage(playerid,red,"ERROR: You can not drop this weapon.");
- new u_savedweapon[13], u_savedammo[13];
- for(new a=0; a<13; a++) GetPlayerWeaponData(playerid, a, u_savedweapon[a], u_savedammo[a]);
- u_savedammo[i] -= dammo;
- ResetPlayerWeapons(playerid);
- new string[128];
- format(string, 128, "[Weapon] You have successfully dropped your %s.", GetUGPWeaponName(weapon));
- SendClientMessage(playerid, green, string);
- for(new a=0; a<13; a++) if(u_savedammo[a]!=0) GivePlayerWeapon(playerid, u_savedweapon[a], u_savedammo[a]);
- if(dammo == ammo) SetPlayerArmedWeapon(playerid,0);
- else SetPlayerArmedWeapon(playerid,weapon);
- return 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement