Wont Drop Weapon
#1

Hey!

Currently scripted /drop command.. why wouldnt this command make a pickup of a gun?

Quote:

CMD:drop(playerid, params[])
{
for (new i = 0; i <= 12; i++)
{
new weapID, ammo, Float, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
GetPlayerWeaponData(playerid, i, weapID, ammo);
CreatePickup(weapID, 3, x, y, z, 0);
}
return 1;
}

Reply
#2

There are many things wrong with this:
  • You're looping through all weapon slots. Do you want to drop all of them?
  • You're defining new variables every loop, this is bad practice. Declare them prior to looping.
  • Same as above, you get the players position every loop. It will not change due to how SA-MP syncs (positions don't update as the server is busy running this command). Do it beforehand.
  • You don't check that the weapon slot actually stores a weapon, so you'd be creating a weapon pickup for Fists in most cases.
  • Weapon IDs are not object IDs. You can find their respective models in the wiki, which range from 331 to 371.
  • You likely don't want to use 0 for the virtual-world param in CreatePickup. Use GetPlayerVirtualWorld directly instead, or -1 for all worlds.
  • You don't store the pickup ID. Don't you want to remove it later?
All in all, this code is simply wrong. What specifically do you want to do? Drop all weapons permanently or allow players to retrieve them?
Reply
#3

basically, drop a weapon player is currently holding, and make it a pickup for next player.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)