Donator Job configuration

= Restrict certain jobs to donator/vip/whatever usergroup =

Creating the usergroup
In order to use this, you will first need some players that have the donator, vip or whatever usergroup. In ulx I believe it's "ulx adduser name donator", but I'm not sure. Here's the guide for FAdmin:

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:GetUserGroup == "donator" end -- The extra check function. Enter nil or nothing to not have an extra check })
 * Make sure you're root user (FAdmin setroot yourname in rcon/server console)
 * Have the donator join your server
 * Once he's in press tab, click the player's name and click Set access (first button)
 * Click new
 * Follow the on-screen instructions and name the usergroup "donator" or "vip" or whatever. Just make sure you remember the name of the group.
 * When making your job, use this template:
 * at the last part, change "donator" to "vip", "special" or whatever you named your group two steps ago. If it was "donator", you can leave it like that. Make sure the double quotes (" ") stay there.
 * Restart the server
 * Ask the donator to try to get the job to test it.

ULX
The above code should work with ULX. If you wish to allow any inherited groups too (eg admin/superadmin), replace this: ply:GetUserGroup == "donator"

by this: ply:CheckGroup("donator") Note: By using this function you acknowledge that things will break if ULX is not installed.

Evolve
If you wish to use Evolve instead of FAdmin, replace:

ply:GetUserGroup == "donator"

With:

ply:GetNWString("EV_UserGroup") == "donator"

Customcheck with multiple groups
Here are examples for custom check functions. They work for shipments and jobs and whatever else uses customcheck functions.

Donators and admins can have this job
function(ply) return ply:GetUserGroup == "donator" == "donator" or ply:IsAdmin end

Superadmin only
function(ply) return ply:IsSuperAdmin end

Multiple groups
Example 1: function(ply) return ply:GetUserGroup == "donator" == "donator" or ply:GetUserGroup == "donator" == "vip" end This can be expanded with more groups.

Example 2: function(ply) return table.HasValue({"donator", "vip", "admin", "superadmin", "mingebag"}, ply:GetUserGroup == "donator") end

Example 3: customCheck = function(ply) return ply:IsUserGroup("donator") or ply:IsAdmin end --This is for a donator only job, and allow an Admin to be it.--

Making clients see entities even though they can't buy them
This happens be default since DarkRP 2.5.0. To disable this, set GM.Config.hideNonBuyable to true in your settings.lua.

Custom fail messages
When customCheck says a player can't buy something, you might want to change the message it sends to this player. Here's how to do it: customCheck = function(ply) return ply:IsUserGroup("donator") end, -- The customcheck function CustomCheckFailMsg = "You need to be a donator to become a Hobo." -- The message it sends to the client This works with shipments, jobs, Ammo, vehicles and custom jobs.

Full example: TEAM_HOBO = DarkRP.createJob("Hobo", {	color = Color(80, 45, 0, 255),	model = "models/player/corpse1.mdl",	description = The lowest member of society. All people see you laugh.		You have no home.		Beg for your food and money		Sing for everyone who passes to get money		Make your own wooden home,	weapons = {"weapon_bugbait"},	command = "hobo",	max = 5,	salary = 0,	admin = 0,	vote = false,	hasLicense = false,	customCheck = function(ply) return ply:IsUserGroup("donator") end,	CustomCheckFailMsg = "You need to be a donator to become a Hobo." })

You might want the custom fail message to be dynamic (show one message when the player is not a donator, show another one when the player has too much money. customCheck = function(ply) return ply:IsUserGroup("donator") and ply:getDarkRPVar("money") < 1000 end, -- The customcheck function CustomCheckFailMsg = function(ply) return ply:getDarkRPVar("money") >= 1000 and "You're too rich!" or not ply:IsUserGroup("donator") and "You need to be a donator to become a Hobo." end, -- The message it sends to the clientTEAM_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:GetUserGroup == "donator" end -- The extra check function. Enter nil or nothing to not have an extra check }) 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:GetUserGroup == "donator" or ply:IsAdmin end, -- The extra check function. Enter nil or nothing to not have a restriction CustomCheckFailMsg = "This job is VIP only!" -- Allows you to tell the user what went wrong when attempting to switch jobs })