Simple NoNPC's and NoENT's

I would like two seperate codes; one that makes npcs admin only and displays a hudhint that its admin only. And the other with all the same, expect that it blocks ents

No-one? :frowning:

Well admin only sents is already in GMOD.

[editline]08:43PM[/editline]

But as for the NPC code, here’s something that I just put together.

[lua]
hook.Add(“PlayerSpawnNPC”, “AdminOnlyNPC”, function(ply, npc_type, npc_weapon)
if not ply:IsAdmin() then
Notify(ply, 1, 4, “You need to be an Admin to do that!”)
return false
end
end)
[/lua]

For individual entities - I think the request is to disallow any non-admin from spawning a SENT or NPC.

Let’s see. This might work - use restrict_sent_npc to toggle it.

[lua]
local RestrictSpawningConvar = CreateConVar(“restrict_sent_npc”, “0”)
local function RestrictSpawnNPC(ply, npc, weapon)
if (not ply:IsAdmin()) and RestrictSpawningConVar:GetBool() then
ply:ChatPrint(“Non-admins can’t currently spawn NPCs”)
return false
end
end
hook.Add(“PlayerSpawnNPC”, “AdminOnlyNPCSpawn”, RestrictSpawnNPC)

local function RestrictSpawnSENT(ply, sent)
if (not ply:IsAdmin()) and RestrictSpawningConVar:GetBool() then
ply:ChatPrint(“Non-admins can’t currently spawn SENTs”)
return false
end
end
hook.Add(“PlayerSpawnSENT”, “AdminOnlySENTSpawn”, RestrictSpawnSENT)
[/lua]