From 4f8207bef1b98c210f031b667fd3c5e77657008e Mon Sep 17 00:00:00 2001 From: Rubat <3299036+robotboy655@users.noreply.github.com> Date: Wed, 8 Jun 2022 18:28:38 +0300 Subject: [PATCH] Fixed an error when dupe-spawning admin only NPCs without player obj --- garrysmod/gamemodes/sandbox/gamemode/commands.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/garrysmod/gamemodes/sandbox/gamemode/commands.lua b/garrysmod/gamemodes/sandbox/gamemode/commands.lua index 19cd4fd267..24e02ac72d 100644 --- a/garrysmod/gamemodes/sandbox/gamemode/commands.lua +++ b/garrysmod/gamemodes/sandbox/gamemode/commands.lua @@ -376,7 +376,7 @@ local function InternalSpawnNPC( ply, Position, Normal, Class, Equipment, SpawnF return end - local isAdmin = ply:IsAdmin() || game.SinglePlayer() + local isAdmin = ( IsValid( ply ) && ply:IsAdmin() ) || game.SinglePlayer() if ( NPCData.AdminOnly && !isAdmin ) then return end local bDropToFloor = false @@ -687,7 +687,7 @@ AddNPCToDuplicator( "monster_sentry" ) -----------------------------------------------------------]] local function CanPlayerSpawnSENT( ply, EntityName ) - local isAdmin = ply:IsAdmin() || game.SinglePlayer() + local isAdmin = ( IsValid( ply ) && ply:IsAdmin() ) || game.SinglePlayer() -- Make sure this is a SWEP local sent = scripted_ents.GetStored( EntityName )