Only admins and above should be able to spawn NPCs.

Hi, I’m having a problem with players accessing the RPG on my server. They spawn an NPC with it and then kill it to pick it up. Unfortunately, I do need NPCs able to be spawned, but I only want admins to be able to do it, and there’s apparently no way to achieve this without an addon. So, I call forth a lua coder who wishes to be indoctrinated into his knighthood to create me such a script! Thanks and God bless.

function NoNPCForYou( ply, npc_type, npc_weapon )
if !ply:IsAdmin() then
return false
hook.Add(“PlayerSpawnNPC”, “RestrictNPC”, NoNPCForYou)

Toss that in a serverside lua.

Thank you!

[lua]local function WeaponWeaponWeapon( p, wep )
if ( wep:GetClass == “weapon_rpg” ) && ( !p:IsAdmin() ) then
return false
hook.Add( “PlayerCanPickupWeapon”, “”, WeaponWeaponWeapon )[/lua]Would this not be of better use?
Rather than restricting NPCs would it not be better to restrict the weapon?

If its not going to be used again please make that a local function.

I don’t want them to spawn NPCs because all they do is spam it- I do want them to be able to get an RPG at some point, though.

Sorry bout the local function thing.

And his way makes it so you can’t spawn NPC’s with the RPG weapon, which is what I originally thought you meant.

It is what I meant- thank you both for your efforts however :slight_smile: