ULX

Author Topic: ULX Accsess stuff  (Read 7797 times)

0 Members and 2 Guests are viewing this topic.

Offline kennis942

  • Newbie
  • *
  • Posts: 22
  • Karma: 0
ULX Accsess stuff
« 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)

Offline someone920

  • Newbie
  • *
  • Posts: 47
  • Karma: 3
Re: ULX Accsess stuff
« Reply #1 on: April 02, 2010, 10:00:51 AM »
do you mean like console command? I don't quite understand by 'write'.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: ULX Accsess stuff
« Reply #2 on: April 02, 2010, 10:04:00 AM »
Do you mean scripting?
Experiencing God's grace one day at a time.

Offline kennis942

  • Newbie
  • *
  • Posts: 22
  • Karma: 0
Re: ULX Accsess stuff
« Reply #3 on: April 02, 2010, 10:32:34 AM »
yes like if [this user ] has access to slap,
ilke in groups.txt
Code: [Select]
"groupname"
{
       "allow"
       {
                "slap"
        }
}




How do i check if a user has this ( im going to make my own acces tag/flag/key

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: ULX Accsess stuff
« Reply #4 on: April 02, 2010, 10:52:00 AM »
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 to see if the user has access to the tag (or use the convenient 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. Translated commands work off the same principles as the functions above, but add an extra layer for command permissions.
Experiencing God's grace one day at a time.

Offline kennis942

  • Newbie
  • *
  • Posts: 22
  • Karma: 0
Re: ULX Accsess stuff
« Reply #5 on: April 02, 2010, 11:01:00 AM »
its for allowing to spawn an entity...so yeah ill test that out.

Offline kennis942

  • Newbie
  • *
  • Posts: 22
  • Karma: 0
Re: ULX Accsess stuff
« Reply #6 on: April 02, 2010, 07:59:43 PM »
Now have :
Code: [Select]
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)
« Last Edit: April 02, 2010, 08:02:12 PM by kennis942 »

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: ULX Accsess stuff
« Reply #7 on: April 02, 2010, 08:11:23 PM »
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()
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline kennis942

  • Newbie
  • *
  • Posts: 22
  • Karma: 0
Re: ULX Accsess stuff
« Reply #8 on: April 04, 2010, 02:18:39 PM »
OKAY.... now i got this, and it worked once but after a server restart it didn't work anymore :(

Code: [Select]
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.
« Last Edit: April 04, 2010, 02:36:01 PM by kennis942 »

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: ULX Accsess stuff
« Reply #9 on: April 04, 2010, 02:47:08 PM »
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).
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULX Accsess stuff
« Reply #10 on: April 04, 2010, 02:59:41 PM »
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.
Code: [Select]
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.
Code: [Select]
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
« Last Edit: April 04, 2010, 03:03:43 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline kennis942

  • Newbie
  • *
  • Posts: 22
  • Karma: 0
Re: ULX Accsess stuff
« Reply #11 on: April 04, 2010, 03:13:03 PM »
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 ?
Code: [Select]
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 :
Code: [Select]
--- 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..

« Last Edit: April 04, 2010, 03:18:42 PM by kennis942 »

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: ULX Accsess stuff
« Reply #12 on: April 04, 2010, 03:17:34 PM »
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.
Experiencing God's grace one day at a time.

Offline kennis942

  • Newbie
  • *
  • Posts: 22
  • Karma: 0
Re: ULX Accsess stuff
« Reply #13 on: April 04, 2010, 03:27:27 PM »
i was editimg and you had replyed before i was done. please review.

Offline kennis942

  • Newbie
  • *
  • Posts: 22
  • Karma: 0
Re: ULX Accsess stuff
« Reply #14 on: April 04, 2010, 05:54:21 PM »
Okay now first worry is that with THIS code:
Code: [Select]
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.
« Last Edit: April 04, 2010, 06:17:38 PM by kennis942 »