Ulysses
General => Developers Corner => Topic started by: kennis942 on April 02, 2010, 09:52:27 AM
-
How/what do i need to write something to return if the user is in ULib Group allowed (groups.txt)
-
do you mean like console command? I don't quite understand by 'write'.
-
Do you mean scripting?
-
yes like if [this user ] has access to slap,
ilke in groups.txt
"groupname"
{
"allow"
{
"slap"
}
}
How do i check if a user has this ( im going to make my own acces tag/flag/key
-
Never forget we have documentation here: http://ulyssesmod.net/docs
I'd also recommend you look at ULX for examples, but basically you want to call blah first to setup the access tag, then call ULib.ucl.query (http://ulyssesmod.net/docs/files/lua/ULib/shared/sh_ucl-lua.html#ucl.query) to see if the user has access to the tag (or use the convenient Player:query (http://ulyssesmod.net/docs/files/lua/ULib/shared/sh_ucl-lua.html#Player:query))
That's assuming you don't want to do something command-based or you're not using ULib SVN. If you want to do something command-based and you're using ULib SVN, you should instead look into translated commands here (http://ulyssesmod.net/docs/files/lua/ULib/shared/commands-lua.html). Translated commands work off the same principles as the functions above, but add an extra layer for command permissions.
-
its for allowing to spawn an entity...so yeah ill test that out.
-
Now have :
ucl.registerAccess("PlayerXController","","Allows users to controll the PlayerX")
function PlayX.IsPermitted(ply)
if PlayXIsPermittedHandler then
return PlayXIsPermittedHook(ply)
else
return ucl.query(ply,"PlayerXController",false)
end
end
and it aint working ...
Also tryed issuing this command :
ulx luarun ucl.query(ply,"PlayerXController",false)
L 04/03/2010 - 05:01:11: Lua Error: :1: attempt to index global 'ucl' (a nil value)
:1: attempt to index global 'ucl' (a nil value)
-
Note when looking at the docs, that most (or all?) of the functions are in the ULib namespace--
Basically, it needs to be ULib.ucl.query() instead of just ucl.query()
-
OKAY.... now i got this, and it worked once but after a server restart it didn't work anymore :(
ULib.ucl.registerAccess("PLX","","Allows users to controll the PlayerX")
--- Returns whether a player is permitted to use the player.
-- @param ply Player
-- @return
function PlayX.IsPermitted(ply)
if ULib.ucl.query(ply,"PLX",false) then
print("Allowed access.")
return true
else
return false
end
end
How can i fix that ?
It gives no errors, it just dosent spawn.
-
When you're calling registerAccess(), you're specifying that no groups have access to the command (or an empty group at least, which might be an error condition).
-
I was posting while Megiddo was. I've got more for ya besides what he said.
First tip of Gmod hook and event coding... never return anything (including "true") unless you don't want the hook to be allowed.
Also, some other tips;
I've numbered your lines for example (because I don't know how to get SMF 'code' tag to do it.
01. ULib.ucl.registerAccess("PLX","","Allows users to controll the PlayerX")
02. --- Returns whether a player is permitted to use the player.
03. -- @param ply Player
04. -- @return
05. function PlayX.IsPermitted(ply)
06. if ULib.ucl.query(ply,"PLX",false) then
07. print("Allowed access.")
08.
09. return true
10. else
11. return false
12. end
14. end
The changes below are made on the following tips. (I don't guarantee they will fix your issue, but surely can't hurt.
Line # - Tip
1) ULX turns every command into lower case. Just makes console commands easier to work with. Register "plx" not PLX. (I don't remember if our register command converts)
1) You're feeding the register access a "" group to give default access to. By default, register access grants "no access" if that's done.
5) You're adding on a function to a table. Does PlayX already exist as a table elsewhere in your code?
6) Convert your "PLX" to "plx" to match line 1.
6 to 12) I presume this function is being called from a Gmod prop spawn player hook or similiar. Again, see my first tip of gmod hooks, never return anything unless you don't want it to happen.
Try the following, based on my tips and what information I have regarding your PlayX
I've numbered your lines for example (because I don't know how to get SMF 'code' tag to do it.
ULib.ucl.registerAccess("plx",ULib.ACCESS_SUPERADMIN,"Allows users to controll the PlayerX")
--- Returns whether a player is permitted to use the player.
-- @param ply Player
-- @return
function PlayX.IsPermitted(ply)
if not ULib.ucl.query(ply,"plx",false) then
print("Not Allowed access.")
return false
end
end
-
Well...
1) You're feeding the register access a "" group to give default access to. By default, register access grants "no access" if that's done.
I want nobody to acces it by default ...so isent that rigth then ?
ULib.ucl.registerAccess("plx",ULib.ACCESS_SUPERADMIN,"Allows users to controll the PlayerX")
--- Returns whether a player is permitted to use the player.
-- @param ply Player
-- @return
function PlayX.IsPermitted(ply)
if not ULib.ucl.query(ply,"plx",false) then
print("Not Allowed access.")
return false
end
There is nothing returning what to do with it then .. in the original file ( Released )
This :
--- Returns whether a player is permitted to use the player.
-- @param ply Player
-- @return
function PlayX.IsPermitted(ply)
if PlayXIsPermittedHandler then
return PlayXIsPermittedHook(ply)
else
return ply:IsAdmin()
end
end
But the "PlayXIsPermittedHook(ply)" dont exist so i emailed the author and he said i could just remove it..thats why this is kinda messed up..
-
Well... I want nobody to acces it by default ...so isent that rigth then ?
You should pass nil instead of an empty string. Always pass nil if you want to leave something unspecified.
-
i was editimg and you had replyed before i was done. please review.
-
Okay now first worry is that with THIS code:
ULib.ucl.registerAccess("plx",nil,"Allows users to controll the PlayerX")
--- Returns whether a player is permitted to use the player.
-- @param ply Player
-- @return
function PlayX.IsPermitted(ply)
if not ULib.ucl.query(ply,"plx",false) then
print("Not Allowed access.")
return false
else
print("PlayerX Access.")
return ULib.ucl.query(ply,"plx",false)
end
end
Okay so now it works... thanks for your help.
-
Personally, I've no idea what PlayX is... you'd have to look at the whole picture to determine why it's not working. I thought you were using a standard gmod hook
I didn't know you were returning false or true to a totally different script's hook system..true and false returned to it may have totally different results.
Knowing what you do now with the UCL query test of a player of a Ulib registered player, you should be able to work with whatever PlayX author and design the test for it.
As for not being able to see the results...you need to research how to see your server's console. Various hosting companies have different ways, and there is also always HLSW or software like it.