Ulysses
General => Developers Corner => Topic started by: Wolfy_ on August 28, 2015, 06:30:01 AM
-
Hello,
I am just wondering whether it is at all possible to restrict ULX access, for my mods & admins, by jobs.
For example, an admin cannot use any of his administrative commands unless he is the job, 'TEAM_ADMIN'
Thank you very much for your help!
-
ULX has no way to stop admin commands based on teams/jobs/roles/, only groups.
You can prevent RP commands based on jobss -Per DarkRP wiki
http://wiki.darkrp.com/index.php/Donator_Job_configuration#Restrict_certain_jobs_to_donator.2Fvip.2Fwhatever_usergroup (http://wiki.darkrp.com/index.php/Donator_Job_configuration#Restrict_certain_jobs_to_donator.2Fvip.2Fwhatever_usergroup)
-
Well technically, in theory, you could run an if statement to determine if the calling player is in a specific DarkRP Team.
-
Definitely, but where would be the best place to put this if statement, after each command? Or is there a more efficient way of doing it?
-
It would have to be in each command you want to lock to the jobs.
-
If you want to prevent them from doing any moderation, in effect making them a regular user, unless in a certain job then you could set up a loop that checks the jobs of the players and if they are in the correct job then it promotes them to admin. Otherwise they are demoted to a normal group. This would require a file with the names of your staff and what group you want them to be promoted to when in the correct job.
The 'checking function' would be put in it's own lua file in either an addon folder or directly in the lua/autorun/ folder. It could run every few seconds or on the Think hook. It reads the file and stores all the staff member's SteamIDs and ranks in a table. Going through all the players it checks their SteamID against the table. When it finds a match it promotes/demotes the player according to their job. It could check to see if the player is already in the staff rank/not so it wouldn't continuously set their group to the same thing.
-
Do NOT use a think hook, at least, not without a time/count buffer, say every 10th or higher frame.
Every think hook would be extremely inefficient, running a getall loop every think.
Wow that could lag.
Ulib includes some hooks that monitor for ULX (or any ULib based really) command callbacks.
During the callback, you can return false and prevent the command from running.
If you're going to stick with ULib, I'd use those.
Add a team check and you should be golden.
See;
ULibCommandCalled (http://ulyssesmod.net/docs/files/lua/ulib/shared/defines-lua.html#ULibCommandCalled)
Possibly;
ULibPostTranslatedCommand (http://ulyssesmod.net/docs/files/lua/ulib/shared/defines-lua.html#ULibPostTranslatedCommand)