Getting a Metrocop NPC to use a custom model

Hey all. How would I go about getting a Metrocop NPC to use a custom (non replacement) model? It’s for my player model pack.

You would have to create a custom entity (it’s real easy though).

Like, when you initialize the entity you create the regular npc, then just use npc:SetModel()

Can you give me any help making it then?

Sure. I think it’d be like this:

init.lua
[lua]AddCSLuaFile( “cl_init.lua” )
AddCSLuaFile( “shared.lua” )

include( “shared.lua” )

function ENT:SpawnFunction(p,trace)
local e = ents.Create(“npc_metropolice”)
e:SetPos(trace.HitPos)
e:SetModel(“yourmodel”)
e:Activate()
e:Spawn()
return e
end[/lua]

shared.lua
[lua]ENT.Type = “anim”
ENT.Base = “base_anim”
ENT.PrintName = “New Metrocop”
ENT.Author = “Entoros + Omolong”

ENT.Spawnable = false
ENT.AdminSpawnable = true[/lua]

cl_init.lua
[lua]include(“shared.lua”)

function ENT:Draw()
self.Entity:DrawModel()
end[/lua]

I’m not too experienced with all this, but it seems right.

It spawns the entity ok, but the cop has no weapons and is still the base model.

Hmm. Try this:

init.lua
[lua]AddCSLuaFile( “cl_init.lua” )
AddCSLuaFile( “shared.lua” )

include( “shared.lua” )

function ENT:SpawnFunction(p,trace)
local e = ents.Create(“npc_metropolice”)
e:SetPos(trace.HitPos)
e:SetModel(“yourmodel”)
e:Give(“ai_weapon_smg1”)
e:Activate()
e:Spawn()

return e

end

function ENT:Initialize()
self.Entity:SetModel(“yourmodel”)
end[/lua]

And remember to replace “yourmodel” :stuck_out_tongue:

Still uses a custom model.

Wasn’t that the idea?

I meant standard model.

Gotcha. How are you reloading the entity, just switching maps?

Also, try taking out the ENT:Draw() function in the cl_init.lua.

Yeah. Still has the standard model.

Gah. Well, it’s probable that NPCs can’t have their models overriden, as that would mess up the animations and such. Sorry, can’t really help you much further.

Well you could easily make your own NPC. Let me dig it up.

Silverlan fixed it for us. Just sorting out some bugs in it.

[lua]local Category = “LolNpc Category”

local NPC = { Name = “MetroCop Custom Model”,
Class = “npc_metrocop”, --Not sure if thats the right one
Model = “lolmodel/modelnpc.mdl”,
Health = “100”,
Category = Category }

list.Set( “NPC”, “npc_ianscott_security”, NPC )[/lua]

EDIT: Oh okay, hope I helped.

Tried that, didn’t work. I’m using Silverlan’s one now.

Post Silverlans one then, because the 2 posts above looked like it should work…

It is in 2 chunks. I need to get permission first. Only me, him and Shotgunguy have it that I know of.

Some NPCs just ignore the ‘model’ keyvalue, thus you can’t do that the normal way. Aside from that you can’t have more than one NPC of one class in the spawnmenu.
I had to rewrite parts of the original code that is used to spawn the NPCs through the spawnmenu to bypass both of that.

Can I release Silverlan or do you want to?