PivityGmodStore

Adding a custom check (donators, jobs, levels, etc)

The custom check is a part of every boost. It is there to restrict certain boosts to certain people.

Here is what it will look like by default in any booster file you open.

CustomCheck = function( ply )
return false
end,
CustomCheckFailMessage = "Your dick must be 20 inches to buy this boost.",

Now let me quickly explain what the CustomCheck does.


The CustomCheck is a lua function that is ran when someone tries to purchase a boost. If the code in there returns true then the player can buy the boost. If it returns false then the player will be denied and the CustomCheckFailMessage will display.

You may have seen the same practice when working with entities and jobs in DarkRP. If you have then great, you will probably know what to do here!

Now how do you restrict certain people from it?


Donator Ranks

Since it is common to restrict it to donators, I have made this one really easy. In the config file you can add your donator teams to the CH_BoostUpgrades.Config.DonatorRanks table.

Now in the boost, you can use this code:

CustomCheck = function( ply )
return CH_BoostUpgrades.Config.DonatorRanks[ ply:GetUserGroup() ]
end,
CustomCheckFailMessage = "This boost is restricted to donators only!",


Leveling System (https://github.com/uen/Leveling-System)

This example will restrict the boost to a certain level using the leveling system above. It will vary for other leveling systems, depending on their metafunction to get the players level.

CustomCheck = function( ply )
return ply:getLevel() >= 10
end,
CustomCheckFailMessage = "This boost is restricted to level 10 and above!",

So to explain this, it will return true if the player is level 10 or above and false if the player is below level 10. And as stated above, true is the green light and false is the red light.


Team/Job

Since it is common to restrict it to jobs, I have made this one really easy. In the config file you can add your allowed jobs/teams to the CH_BoostUpgrades.Config.AllowedTeams table.

Now in the boost, you can use this code:

CustomCheck = function( ply )
return CH_BoostUpgrades.Config.AllowedTeams[ team.GetName( ply:Team() ) ]
end,
CustomCheckFailMessage = "This boost is restricted to certain jobs only!",


I will add more examples to this guide as people request them!

Can't find what you're looking for?

Contact support