Articles on: Garry's Mod

Restrict Prop Spawning to specific DarkRP Jobs

Restricting prop spawning to only specific job(s)


Sometimes you may only want a certain job (e.g. Mayor) to spawn props, luckily this guide should help you solve this very problem!

Making a simple lua script to restrict prop spawning to specific jobs


In the guide below we'll go over a very simple lua script that will allow you to only allow certain jobs to spawn props!

First create the file!
/garrysmod/addons/restrict_prop_spawning/lua/autorun/restrict_prop_spawning.lua

Once that is finished you can copy and paste the code below!
/*
You can add as many jobs as you would like
The array of jobs below will be ALLOWED to spawn props, any other not in this list will not!
*/

local propSpawningJobs = {
  [TEAM_BUILDER] = true,
  [TEAM_MOBBOSS] = true,
  [TEAM_HOBO] = true,
}

hook.Add("PlayerSpawnProp", "JobSpawnPropRestrict", function(ply)
  if not propSpawningJobs[ply:Team()] then return false end
end)


That's it! A very simple but effective solution to allowing certain jobs to spawn props! This works with any DarkRP gamemode (such as StarwarsRP, HogwartsRP, etc..)!

Updated on: 27/04/2023

Was this article helpful?

Share your feedback

Cancel

Thank you!