• GetNWString("usergroup") returns nothing
    21 replies, posted
Hello, Am running a darkrp server where am using ulx and fadmin both, I have recently noticed that for some players, their Networked string "usergroup" contains nothing I have also tried to set it manually in the server console but when I print it I got nothing. I don't know if this problem is coming from user side or server side. Thanks.
How are you trying to get the string
I just type this in the server console : lua_run print(player.GetByID(X):GetNWString("usergroup")) and it prints nothing. I did that because some of my donators cannot access vip jobs, it was telling them that hey don't have the rank but they do and in the customcheck I check the user group by using GetNWString("usergroup"). [editline]30th August 2014[/editline] I also tried this: [CODE]player.GetByID(X):SetNWString("usergroup", "vip") print(player.GetByID(X):GetNWString("usergroup")) -- I got nothing ![/CODE] I have this issue only with some vips not all.
I would recommend looking at [URL="http://wiki.darkrp.com/index.php/Donator_Job_configuration"]this[/URL], and making sure your mods are configured properly (ulx). If you're really curious about getting everyone's usergroup, you can lua_run_cl this: [code] for _, v in pairs (player.GetAll()) do print(v:Nick().." "..v:GetNWString("usergroup")) end [/code]
Everything is configured correctly as far as I know. The thing that I can't understand is the fact that I got vips that are able to choose vip jobs but other vips and they are few can't choose the vip job. When I access to the NWString Fot those with no problem I got the usergroup but for others that can't choose job i got nothing.
Paste an example of your customcheck function for your jobs.
Ok here is an exemple : customCheck = function(ply) return ply:GetNWString("usergroup") == "vip" end
If you're using ULX to set ranks use [code] ply:GetUserGroup() == "donator" [/code] Certain VIPs might be set to vip in FAdmin, allowing them to use it. I don't know if ULX sets an NWString for usergroups.
It's UserGroup, not usergroup but you shouldn't be doing GetNWString anyways. [url]http://wiki.garrysmod.com/page/Player/GetUserGroup[/url] [editline]29th August 2014[/editline] There's also [url]http://wiki.garrysmod.com/page/Player/IsUserGroup[/url]
Pretty sure GetUserGroup just returns the nwstring.. [editline]30th August 2014[/editline] [QUOTE=Lolcats;45840300]If you're using ULX to set ranks use [code] ply:GetUserGroup() == "donator" [/code] Certain VIPs might be set to vip in FAdmin, allowing them to use it. I don't know if ULX sets an NWString for usergroups.[/QUOTE] Not sure what you're trying to do here, but getting the user group and comparing it to another will not set it :v:
its not "usergroup" its "UserGroup"
I'm literally reading right off of what it says in the [URL="http://wiki.darkrp.com/index.php/Donator_Job_configuration"]first link[/URL] I posted. It's not my fault there's 4 different ways to set someone's "usergroup" because nobody can agree on a standard. Bottom line is the OP should just use [code] customCheck = function(ply) return ply:GetUserGroup() == "vip" end, [/code] and it should work. If it doesn't, then there's a different problem.
I am now using GetUserGroup() instead of GetNWString("usergroup") and it work just fine. But still can't understand why GetNWString("usergroup") is not returning the usergroup for some players. Thank you.
Are you sure they have a group set up? Here's an example of what I do ( in tutorials since I don't use NW vars anylonger because they continuously re-query ): [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_gm_specific_darkrp/darkrp_customcheck_isvip_via_list_or_group_or_admin_check.lua.html[/url] [b]Hopefully these tutorials and information helps. As always, to view the Lua from any of my tutorials to enable copy/pasting ( HTML doesn't copy/paste well in terms of HTML / CSS Highlighted Lua ), remove .html from the url.[/b] So, I grab the value, then cache the value, ensure I keep it for a minimum of 5 seconds before allowing it to requery. But, if you're notice, I use || "guest" so that if the user doesn't have a group, it is set to something "default".
[QUOTE=Bnadm;45847077]I am now using GetUserGroup() instead of GetNWString("usergroup") and it work just fine. But still can't understand why GetNWString("usergroup") is not returning the usergroup for some players. Thank you.[/QUOTE] Because it's Player:GetNWString("UserGroup") The second arg is the default group to use if the result doesn't exist. e.g "user" [QUOTE=mrweegeeman;45841558]its not "usergroup" its "UserGroup"[/QUOTE] This guy already said this like 3 posts above me, too. [img]http://i.imgur.com/IzC5avB.png[/img] You can see so yourself.
It should be GetNWString instead of GetNetworkedString unless they both do the same thing ( which the name suggests it should, but I've seen things named similarly that did different things )...
[QUOTE=Acecool;45849173]Are you sure they have a group set up? Here's an example of what I do ( in tutorials since I don't use NW vars anylonger because they continuously re-query ): [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_gm_specific_darkrp/darkrp_customcheck_isvip_via_list_or_group_or_admin_check.lua.html[/url] [b]Hopefully these tutorials and information helps. As always, to view the Lua from any of my tutorials to enable copy/pasting ( HTML doesn't copy/paste well in terms of HTML / CSS Highlighted Lua ), remove .html from the url.[/b] So, I grab the value, then cache the value, ensure I keep it for a minimum of 5 seconds before allowing it to requery. But, if you're notice, I use || "guest" so that if the user doesn't have a group, it is set to something "default".[/QUOTE] Will you stop giving a generic 'tutorial' to fix a very specific issue? It really doesn't help, you need to start helping people on a case per case if you want it to have any effect. Metaphor: Someone wants to know how to change a fuse, And you just gave them the whole manual for the entire car. Be more specific....
[QUOTE=Acecool;45854406]It should be GetNWString instead of GetNetworkedString unless they both do the same thing ( which the name suggests it should, but I've seen things named similarly that did different things )...[/QUOTE] They do the same thing.
[QUOTE=dingusnin;45855242]Will you stop giving a generic 'tutorial' to fix a very specific issue? It really doesn't help, you need to start helping people on a case per case if you want it to have any effect. Metaphor: Someone wants to know how to change a fuse, And you just gave them the whole manual for the entire car. Be more specific....[/QUOTE] It does what the OP wants it to do, but better ( by caching the result instead of requerying each time ), it also sets and returns a default if no group is set. It can compare if in a certain group, or if the user is in a list of groups.
[QUOTE=dingusnin;45855242]Will you stop giving a generic 'tutorial' to fix a very specific issue? It really doesn't help, you need to start helping people on a case per case if you want it to have any effect. Metaphor: Someone wants to know how to change a fuse, And you just gave them the whole manual for the entire car. Be more specific....[/QUOTE] I agree 100% Acecool evreytime I read your comments I understand NOTHING. Only 5% of those 'tutorials' actually help. I'll use dingusnin's example: You give them the whole manual, and usually that's fine, but when the fuse is on page 400 and they don't know that, it's just useless... Also, having _ before every single variable is just confusing for new lua coders
I find Acecool's tutorials extremely helpful, I don't see how having "_" before a variable is confusing at all.. it's his style of coding and its unique, but yes people who are very new to lua may find it slightly confusing.
One of my server players wasn't able to get vip jobs because his usergroup variable contains nil, after that he reinstalled gmod and the problem is gone. So to avoid such problem to occure stop using GetNWString("usergroup") and use GetUserGroup() to check for user group. Thank you all for your help and the code you shared. Solved
Sorry, you need to Log In to post a reply to this thread.