General > Developers Corner

Restrict DarkRp job class to certain ulx ranks

<< < (3/3)

JamminR:
pazda, the way you express it, your player wanting to be that job must be an admin and a donator.
It's difficult to be two groups at once, unless you're in a Ulib group where donator inherits admin (I _think_ that would work)

pazda:
! in lua means not, so it's saying if you're not an admin and if you're not a donator then do that

If it weren't for the !s, you'd be right. It's been working fine on my server.

AJ-:
If you took the time to have a look yourself, you would have found the article on the DarkRP wiki regarding custom jobs and that includes code to make it usergroup dependent

pazda:
The page doesn't exist anymore.

louietien:
You can also do so that, only 1 ULX rank or FAdmin rank and or admins can use the job.
Use this code:



--- Code: ---    customCheck = function(ply) return ply:CheckGroup("donator") or ply:IsAdmin() end,
--- End code ---

If you're using FAdmin replace

--- Code: ---ply:CheckGroup("donator")
--- End code ---

with


--- Code: ---ply:GetNWString("usergroup") == "donator" or ply:IsAdmin
--- End code ---

Job Example:

--- Code: ---TEAM_DONATORJOB = DarkRP.createJob("Swat", -- Name
    color = Color(238, 99, 99, 255), -- Team color
    model = "models/player/mossman.mdl", -- Player model
    description = [[As a cook, it is your responsibility to feed the other members of your city.
                            You can spawn a microwave and sell the food you make: /Buymicrowave]],  -- Job description
    weapons = {}, -- Additional weapons
    command = "Swat", -- Command to become the job
    max = 2, -- Maximum amount of said job
    salary = 45, -- Salary
    admin = 0, -- Requires Admin? 1 for yes, 0 for no.
    vote = false, -- Do they need to vote? true for yes, false for no.
    hasLicense = false, -- Has a license
    customCheck = function(ply) return ply:GetNWString("usergroup") == "donator" or ply:IsAdmin() end, -- The extra check function. Enter nil or nothing to not have a restriction
--- End code ---

Navigation

[0] Message Index

[*] Previous page

Go to full version