Difference between revisions of "Donator Job configuration"

From Official DarkRP Wiki
Jump to navigation Jump to search
m (I added a FAdmin Donator+Admin only.)
Line 96: Line 96:
 
'''Example 2:'''
 
'''Example 2:'''
 
{{Code|1=function(ply) return table.HasValue({"donator", "vip", "admin", "superadmin", "mingebag"}, ply:GetNWString("usergroup")) end}}
 
{{Code|1=function(ply) return table.HasValue({"donator", "vip", "admin", "superadmin", "mingebag"}, ply:GetNWString("usergroup")) end}}
 +
 +
'''Example 3:'''
 +
{{Code|1=customCheck = function(ply) return CLIENT or ply:IsUserGroup("donator") or ply:IsAdmin() end}} --This is for FAdmin Donator Only job, and allow an Admin to be it.--
 +
  
 
==Making clients see entities even though they can't buy them==
 
==Making clients see entities even though they can't buy them==

Revision as of 09:45, 1 August 2013

DarkRP: Donator Job configuration
Page white text.png Description:Adding and configuring donator jobs.
User.png Original Author:Mr. Phy FPtje
Calendar.png Created:December 20, 2009

Restrict certain jobs to donator/vip/whatever usergroup

Details

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:

* 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 = AddExtraTeam("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" 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

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 = AddExtraTeam("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 an extra check
)

ULX

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

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

With:

ply:GetUserGroup() == "donator"

Or if you wish to allow any inherited groups too (eg admin/superadmin), replace it with:

ply:CheckGroup("donator")

Evolve

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

ply:GetNWString("usergroup")

With:

ply:GetNWString("EV_UserGroup")

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:GetNWString("usergroup") == "donator" or ply:IsAdmin() end

Superadmin only

function(ply) return ply:IsSuperAdmin() end

Multiple groups

Example 1:

function(ply) return ply:GetNWString("usergroup") == "donator" or ply:GetNWString("usergroup") == "vip" end

This can be expanded with more groups.

Example 2:

function(ply) return table.HasValue({"donator", "vip", "admin", "superadmin", "mingebag"}, ply:GetNWString("usergroup")) end

Example 3:

customCheck = function(ply) return CLIENT or ply:IsUserGroup("donator") or ply:IsAdmin() end

--This is for FAdmin Donator Only job, and allow an Admin to be it.--


Making clients see entities even though they can't buy them

Simply make the client think they can buy it. Mind the parentheses "( )"! They're important!

Example 1:

function(ply) return CLIENT or (ply:GetNWString("usergroup") == "donator" or ply:IsAdmin()) end

Example 2:

function(ply) return CLIENT or (ply:GetNWString("usergroup") == "donator" or ply:GetNWString("usergroup") == "vip" end)

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 CLIENT or ply:IsUserGroup("Asshole") end, -- The customcheck function
CustomCheckFailMsg = "You need to be an asshole to become a hobo." -- The message it sends to the client

This works with shipments, jobs, Ammo, vehicles and whatever I forgot to mention.

Full example:

TEAM_HOBO = AddExtraTeam("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 CLIENT or ply:IsUserGroup("Asshole") end,
	CustomCheckFailMsg = "You need to be an asshole to become a hobo."
})