diff --git a/garrysmod/gamemodes/sandbox/gamemode/commands.lua b/garrysmod/gamemodes/sandbox/gamemode/commands.lua index 4d017f424a..a7d2db80a5 100644 --- a/garrysmod/gamemodes/sandbox/gamemode/commands.lua +++ b/garrysmod/gamemodes/sandbox/gamemode/commands.lua @@ -463,8 +463,10 @@ local function InternalSpawnNPC( NPCData, ply, Position, Normal, Class, Equipmen -- -- Does this NPC have a specified model? If so, use it. -- + local NPCModel if ( NPCData.Model ) then - NPC:SetModel( NPCData.Model ) + NPCModel = (type(NPCData.Model) == "string" and NPCData.Model) or ( #NPCData.Model > 0 and NPCData.Model[math.random(#NPCData.Model)] ) or "models/error.mdl" + NPC:SetModel( NPCModel ) end -- @@ -559,8 +561,8 @@ local function InternalSpawnNPC( NPCData, ply, Position, Normal, Class, Equipmen -- For those NPCs that set their model/skin in Spawn function -- We have to keep the call above for NPCs that want a model set by Spawn() time -- BAD: They may adversly affect entity collision bounds - if ( NPCData.Model && NPC:GetModel():lower() != NPCData.Model:lower() ) then - NPC:SetModel( NPCData.Model ) + if ( NPCModel && NPC:GetModel():lower() != NPCModel:lower() ) then + NPC:SetModel( NPCModel ) end if ( NPCData.Skin ) then NPC:SetSkin( NPCData.Skin )