Ulysses
General => Developers Corner => Topic started by: Bite That Apple on January 13, 2015, 09:22:43 PM
-
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 :(
for k, v in pairs(ply:GetWeapons()) do
MsgN(v)
end
OUTPUT
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]
-
Hello,
maybe this clientsided function may be of use to you: weapon:GetPrintName() (http://wiki.garrysmod.com/page/Weapon/GetPrintName)
Hope this was somewhat useful,
Avoid
-
Hello,
maybe this clientsided function may be of use to you: weapon:GetPrintName() (http://wiki.garrysmod.com/page/Weapon/GetPrintName)
Hope this was somewhat useful,
Avoid
ply:GetWeapons() is a server side command.
-
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 (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.
-
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 (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.
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.
-
I believe GetClass() is what you want.
-
"On another topic, is there a way to check is a players is Noclipping"
PlayerNoClip (http://wiki.garrysmod.com/page/GM/PlayerNoClip) is called when a player wants to turn on/off noclip
You can probably do stuff like that with that hook
-
"On another topic, is there a way to check is a players is Noclipping"
PlayerNoClip (http://wiki.garrysmod.com/page/GM/PlayerNoClip) is called when a player wants to turn on/off noclip
You can probably do stuff like that with that hook
On another topic, is there a way to check is a players is Noclipping, because the command PlayerNoClip is very buggy.
------------------------------------
I believe GetClass() is what you want.
Thank you, that's what I was looking for, but sadly, due to the fact that PlayerNoClip is so buggy, my idea failed, but I got it to work with other means.
-
players entire weapons by string, instead of table, because I don't understand tables enough to actually somehow make it work.
Until you learn, your going to be extremely limited in anything you can do in lua, or any programming language for that matter.
Table. Array. Matrix. 3 common terms across various languages.
Learn them Padawan.
Additionally, though I've not done any research what-so-ever, I question playernoclip actually being buggy, instead of just not being used correctly.
We use it in ULX with no issue we know of.
-
Until you learn, your going to be extremely limited in anything you can do in lua, or any programming language for that matter.
Table. Array. Matrix. 3 common terms across various languages.
Learn them Padawan.
I worded it incorrectly, let me try again. I understand tables, but I don't know library enough to actually use all features. There are just some things I don't feel the need to do use unless I really need them, and I'll typically get lucky and get them to work, others; well then we're in this type of situation that I was in.
Additionally, though I've not done any research what-so-ever, I question playernoclip actually being buggy, instead of just not being used correctly.
We use it in ULX with no issue we know of.
Code:
(Whether or not the timer is there doesn't make a difference to the error, it will still error out, and not work)
This simple little piece of code should work, and it DOES, but only half way. This does give the message to the player saying they should not kill while in noclip, but then gives the error which will be located below. Now if you say I'm using it wrong still, obviously my basic understanding of hooks has changed.
[1] -- SERVER SIDE
[2]
[3]function DisableNoclipNoWeps2( ply )
[4] timer.Simple(0.5, function()
[5] if ply:GetMoveType() == 8 then
[6] umsg.Start("PlayerNoNoclipKill", ply)
[7] umsg.String("You are now in noclip do not kill people while in noclip!")
[8] umsg.End()
[9] end
[10] end)
[11]end
[12]hook.Add("PlayerNoClip", "DisableNoclipNoWeps2", DisableNoclipNoWeps2)
ERROR:
[Dev Apple|191|STEAM_0:0:35379784] Lua Error:
[ERROR] addons/apple_noclip_noweapons/lua/autorun/sv_noclip_no.lua:6: attempt to index global 'umsg' (a nil value)
1. unknown - addons/apple_noclip_noweapons/lua/autorun/sv_noclip_no.lua:6
-
What's the client side code you're using to deliver the string to player's attention?
-
What's the client side code you're using to deliver the string to player's attention?
function PlayerSpawnNoKill(data)
chat.AddText(Color(255,255,0),data:ReadString())
end
usermessage.Hook("PlayerSpawnNoKill", PlayerSpawnNoKill)
-
Did you grab from the wrong client side code of your file?
Your noclip user message is named "PlayerNoNoclipKill"
Client side code you posted looks like its from another user message regarding spawn instead of noclip.
-
Did you grab from the wrong client side code of your file?
Your noclip user message is named "PlayerNoNoclipKill"
Client side code you posted looks like its from another user message regarding spawn instead of noclip.
I have three user messages in the client side code, I just copied the first one, because I just thought it was relating to the server side, but it looks like I did it out of order. Either way, it still gives an error.