Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions garrysmod/gamemodes/sandbox/gamemode/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

--
Expand Down Expand Up @@ -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 )
Expand Down