SA-MP Forums Archive
Need help with /give weapon - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need help with /give weapon (/showthread.php?tid=313746)



Need help with /give weapon - milanosie - 27.01.2012

Hey there guy (and girls), I am trying to make a cmd that players can give the gun that they are currently holding to nearby players, Only Problem is, What function should I use to remove/reset the gun that the player is currently holding, for after he "gave" it to the other player?

If anyone could tell me, I will appreciate it


Re: Need help with /give weapon - Norck - 27.01.2012

There is no function that removes only one weapon. But there is a function that removes all player's weapons. So you can put all player's weapons into an array using GetPlayerWeaponData, then remove all weapons using ResetPlayerWeapons and then give all weapons back (excluding a weapon that player should give to another player).


Re: Need help with /give weapon - milanosie - 27.01.2012

Quote:
Originally Posted by Norck
Посмотреть сообщение
There is no function that removes only one weapon. But there is a function that removes all player's weapons. So you can put all player's weapons into an array using GetPlayerWeaponData, then remove all weapons using ResetPlayerWeapons and then give all weapons back (excluding a weapon that player should give to another player).
Hmm, that is making it more complicated then it should be, but if it is the only solution thanks for helping

I really think there should be a function like ClearPlayerWearingWeapon or something,.. would be usefull


Re: Need help with /give weapon - MP2 - 27.01.2012

I'm fairly certain there'll be a function out there somewhere, possibly in the 'Useful Functions' topic or in an include. If not, I could attempt to make it.


Re: Need help with /give weapon - henry jiggy - 27.01.2012

1-Get player weapon data storing it in variables
2-use ResetPlayerWeapons
3-give back all weapons except the one you want to remove

P.S: Weapon Data is tricky and annoys, but this is possible ^^

https://sampwiki.blast.hk/wiki/GetPlayerWeaponData
https://sampwiki.blast.hk/wiki/ResetPlayerWeapons
https://sampwiki.blast.hk/wiki/GetPlayerWeapon

EDIT:

Use GetPlayerWeapon to see the weapon the player is holding and give it to the other player, then the method above.


Re: Need help with /give weapon - MP2 - 27.01.2012

http://pastebin.com/phU8Ffrc

There you go. Tested - seems to work fine. Tell me if there's any problems.


Re: Need help with /give weapon - henry jiggy - 27.01.2012

Yaaaay, dreams come true.

lol

seems nothings wrong with that ^^ hope it works




This forum requires that you wait 120 seconds between posts. Please try again in 19 seconds.

TIME, Y U NO GO FASTER


Re: Need help with /give weapon - milanosie - 27.01.2012

thanks, Could you explain me what stocks do? I am not very experienced with them.


Re: Need help with /give weapon - henry jiggy - 27.01.2012

stocks are basically normal functions, but they dont display a warning when compile if u dont use it, and people usually use those in includes because of that.


Re: Need help with /give weapon - MP2 - 27.01.2012

-removed-