SA-MP Forums Archive
Listing player weapons - 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: Listing player weapons (/showthread.php?tid=638377)



Listing player weapons - grymtn - 30.07.2017

hello i have a take gun and put gun command. I can list my weapons in car that i can take but i cant list the weapons that player has on himself. anyone has an idea or tutorail how to list these weapons ?

Example:
if i have weapon id 24(desert eagle) with 87 bullets and a weapon id 25(shotgun) with 24 bullets i want to see them on DIALOG_TYPE_LIST without holding it in my hand. both ammo and weapon name


Re: Listing player weapons - BlackBank - 31.07.2017

You could use GetPlayerWeaponData for it, there is even an example on the wiki page how to get all those weapons: https://sampwiki.blast.hk/wiki/GetPlayerWeaponData


Re: Listing player weapons - grymtn - 31.07.2017

but it lists like

emptyline
emptyline
desert eagle
shotgun
emptyline
...
..

i need to list like only 2 weapons and when i put the weapon to car it cant search for specific weapon on my character and delete it. thats why i need a tutorial

i mean i cant say in code like delete weapon id 25 from player i need to say delete weapon slot 3 from player shotgun is id 3 i believe


Re: Listing player weapons - Dayrion - 31.07.2017

Well, you have to check if the line is empty or not. How? Check the length of the line with strlen. If strlen = 0, the player doesn't have the weapon.


Re: Listing player weapons - grymtn - 31.07.2017

yeah i dont know how to do that thats my ptoblem i need tutorials that i can develop on. for take gun i did like carslot1 carslot2 carslot3 if theres no gun in carslots they return 0 to me and if they are 0 i told to format the string to freeslot and write that but i dont know how to skip empty lines


Re: Listing player weapons - Jefff - 31.07.2017

https://sampforum.blast.hk/showthread.php?tid=571253


Re: Listing player weapons - grymtn - 31.07.2017

thank you its more like what i want i can play on this