Author Topic: adding and reading access commands  (Read 2807 times)

0 Members and 1 Guest are viewing this topic.

Offline centran

  • Newbie
  • *
  • Posts: 43
  • Karma: 8
adding and reading access commands
« on: December 04, 2012, 09:27:13 AM »
When you add a new command it automatically creates access rights to that command so you can choose what groups can run the command.

First question is if it is possible to check if the calling_ply has access to a certain command. I know the system automatically handles the access so why would you need to ever check is calling_ply has access to the command? Well keep reading and it might make more sense.
Second question is if you can add "fake" commands. What I mean by that is the commands will show up to add group access to but they don't do anything.

So if this all seems confusing what i am asking then maybe if I explain what i am trying to do it will clarify things.
I would like to set certain ban ranges for different groups. So for example an admin could only ban for 6 hours but a super admin can ban for a day. Now i don't want to have to create a separate ban command for each group. I want anyone to be able to use the same !ban command. It would be fine if I have to create fake commands to do this but I would like to check in the main ban command if they have access to another "command" and if so then they can only ban for a certain range.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: adding and reading access commands
« Reply #1 on: December 04, 2012, 01:10:19 PM »
Everything you're talking about is possible. But there's no reason to do it because your goal is already directly supported by the permission system. Want group "llama" to be able to ban up to 6 hours? Use the following command:

Code: [Select]
ulx groupallow llama "ulx ban" "* 1:6h"
Read this as: Allow group "llama" to ban anyone they can normally target (*), but only allow them to ban for lengths between 1 minute and 6 hours (1:6h).
Experiencing God's grace one day at a time.

Offline centran

  • Newbie
  • *
  • Posts: 43
  • Karma: 8
Re: adding and reading access commands
« Reply #2 on: December 04, 2012, 03:54:13 PM »
Thank you that was what i was looking for.

In case someone was wondering I will answer my initial question of adding additional access commands to check against you would do something like this...
Code: [Select]
local whateverAccess = "ulx whatever"
if SERVER then ULib.ucl.registerAccess( whateverAccess, ULib.ACCESS_ALL, "Description", "Other" ) end
then check it like this...
Code: [Select]
if ULib.ucl.query( ply, whateverAccess )
« Last Edit: December 04, 2012, 03:56:39 PM by centran »