SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Thread Tools Display Modes
Old 29/04/2018, 02:07 PM   #1
Huge Clucker
Join Date: May 2016
Posts: 234
Reputation: 5
Default Wont Drop Weapon


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

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;
NoteND is offline   Reply With Quote
Old 29/04/2018, 02:52 PM   #2
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,139
Reputation: 445
Default Re: Wont Drop Weapon

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?
Abagail is offline   Reply With Quote
Old 29/04/2018, 02:54 PM   #3
Huge Clucker
Join Date: May 2016
Posts: 234
Reputation: 5
Default Re: Wont Drop Weapon

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

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me with weapon drop [+Rep] kesarthakur Scripting Help 1 15/05/2015 09:38 AM
drop weapon P<3TS Scripting Help 6 29/07/2012 08:46 AM
[help] weapon drop BurningSWA Help Archive 2 01/05/2010 03:54 PM
Weapon drop.. _Vortex Help Archive 1 15/11/2009 11:04 PM
help with weapon drop _ReloadeD_ Help Archive 4 10/04/2009 07:44 PM

All times are GMT. The time now is 02:13 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.