Restricting entities to certain jobs and donators
If you want to restrict entities to certain jobs, here is an example:
DarkRP.createEntity("Crate", {
ent = "ch_farming_crate",
model = "models/craphead_scripts/ch_farming/utility/crate.mdl",
price = 250,
max = 5,
category = "Farming",
cmd = "buycropscrate",
allowed = {TEAM_FARMER, TEAM_GANGSTER, TEAM_WHATEVER},
})
You can read more about customizing entities in the DarkRP Wiki (CustomEntityFields)
The same practice goes for weapons. As you can already see in the file ch_farming/lua/ch_farming/shared/ch_farming_darkrpadds.lua on line 146. The weapons are already using the allowed option. You can delete the entire line if you wish to allow everyone to buy the tools.
Donator Example
Here is another example of how to make an item only available for donators.
DarkRP.createEntity("Crate", {
ent = "ch_farming_crate",
model = "models/craphead_scripts/ch_farming/utility/crate.mdl",
price = 250,
max = 5,
category = "Farming",
cmd = "buycropscrate",
customCheck = function(ply) return ply:GetUserGroup() == "donator" end,
CustomCheckFailMsg = function(ply, entTable) return "You need to be a donator to buy this entity!" end,
})
Hope this helps you!