Here you go..
Take this..
if SERVER then
local npcadmin = 10 --ADMIN NPC LIMIT
local npcelse = 2 --USER NPC LIMIT
function PlayerSpawnNPC( ply, npc_type, npc_weapon ) -- Sets default data for a player when he joins.
local gnpcs = ply:GetCount("npcs") + 1
local gmaxnpcs = 0
if ply:IsAdmin() then
gmaxnpcs = npcadmin
else
gmaxnpcs = npcelse
end
if gnpcs > gmaxnpcs then
local Text = "You have reached the NPC limit for your usergroup."
ply:SendLua("GAMEMODE:AddNotify(\""..Text.."\", NOTIFY_GENERIC, 5); surface.PlaySound(\"npc/turret_floor/active.wav\")")
return false
end
end
hook.Add( "PlayerSpawnNPC", "mppgspawnnpchook", PlayerSpawnNPC );
end
And put it in a file called npclimit.lua in Addons\ULib\lua\ULib\modules
The 2 lines at the top are where you set the limits.. it's pretty well documented there =)
Also, make sure your server npc limit is set to 1 more than your admin limit. (sbox_maxnpcs <value>)