General > Developers Corner

Listing Players Weapons by String

(1/3) > >>

Bite That Apple:
I've been trying to find a way to list a specific player's weapons, using this command ply:GetWeapons() Though, I don't want that outputs stuff. I just want the string name of the weapon, not the userdata, I don't know what to do with that, and I don't know how to fix it. Help appreciated plz :(


--- Code: --- for k, v in pairs(ply:GetWeapons()) do
MsgN(v)
end

--- End code ---

OUTPUT


--- Code: ---Weapon [113][weapon_crowbar]
Weapon [114][weapon_pistol]
Weapon [115][weapon_smg1]
Weapon [117][weapon_frag]
Weapon [119][weapon_physcannon]
Weapon [120][weapon_crossbow]
Weapon [121][weapon_shotgun]
Weapon [122][weapon_357]
Weapon [123][weapon_rpg]
Weapon [124][weapon_ar2]
Weapon [125][gmod_tool]
Weapon [128][gmod_camera]
Weapon [129][weapon_physgun]
--- End code ---

Avoid:
Hello,
maybe this clientsided function may be of use to you: weapon:GetPrintName()

Hope this was somewhat useful,
Avoid

Bite That Apple:

--- Quote from: Avoid on January 14, 2015, 03:39:14 AM ---Hello,
maybe this clientsided function may be of use to you: weapon:GetPrintName()

Hope this was somewhat useful,
Avoid

--- End quote ---

ply:GetWeapons() is a server side command.

JamminR:
BTA, this same challenge has been discussed somewhere among these forums before.
Likely in Dev corner, but i'm not going to swear to that.
Do some searching for Getweapon or other base lua words and you'll likely find it.
Overall, I think net messages or send lua from server to client had to be done.
Now that I've typed this much, I think I even remember MrPresident having a good solution.

EDIT -
http://forums.ulyssesmod.net/index.php/topic,7697.0.html
Not fully what you want (not full list), but, at least it shows how to do what a person is holding according to the server.

Bite That Apple:

--- Quote from: JamminR on January 14, 2015, 07:29:30 PM ---BTA, this same challenge has been discussed somewhere among these forums before.
Likely in Dev corner, but i'm not going to swear to that.
Do some searching for Getweapon or other base lua words and you'll likely find it.
Overall, I think net messages or send lua from server to client had to be done.
Now that I've typed this much, I think I even remember MrPresident having a good solution.

EDIT -
http://forums.ulyssesmod.net/index.php/topic,7697.0.html
Not fully what you want (not full list), but, at least it shows how to do what a person is holding according to the server.

--- End quote ---

I can do that without an issue, I'm just looking for a way to like a players entire weapons by string, instead of table, because I don't understand tables enough to actually somehow make it work.

----

On another topic, is there a way to check is a players is Noclipping, because the command PlayerNoClip is very buggy. I might as well just come out and see what I'm searching for or trying to make.

I'm trying to make it so that when a player is in noclip, there weapon gets switched to Physigun, and they can not equip a any other weapon. Also, or I'm trying to make it so that when a player enters noclip, all their weapons get removed, and they're only given physgun and tool gun. If anyone can direct me in the correct direction, that would be nice.

Navigation

[0] Message Index

[#] Next page

Go to full version