Donator Job configuration
DarkRP: Donator Job configuration |
![]() | Adding and configuring donator jobs. |
![]() | Mr. Phy FPtje |
![]() | December 20, 2009 |
![]() | October 25, 2013 |
Restrict certain jobs to donator/vip/whatever usergroup[edit]
Details[edit]
Creating the usergroup[edit]
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:
- 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:
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
})
- 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.
NOTES[edit]
If the extra check says only donators can get the job, then admins and superadmins won't be able to get the job, because they're not donators. If you want the admins to be able to get the job, use this template to make the job:
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
})
ULX[edit]
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[edit]
If you wish to use Evolve instead of FAdmin, replace:
ply:GetUserGroup() == "donator"
With:
ply:GetNWString("EV_UserGroup") == "donator"
Customcheck with multiple groups[edit]
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[edit]
function(ply) return ply:GetUserGroup() == "donator" == "donator" or ply:IsAdmin() end
Superadmin only[edit]
function(ply) return ply:IsSuperAdmin() end
Multiple groups[edit]
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[edit]
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[edit]
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 client
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
}) 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
})