So I am hosting a server and I am trying to spawn a entity on map start. I know that this is kind of the code you need
[CODE]
hook.Add( "InitPostEntity", "createdealer", function()
local dealer = ents.Create("scripted_entity")
dealer:SetPos(Vector(6573, 4321, 202))
dealer:SetAngles(Angle(0, 0, 0))
dealer:SetModel("models/Characters/Hostage_02.mdl")
dealer:SetSolid(SOLID_BBOX)
dealer:Spawn()
end)
[/CODE]
So I dont understand how to make it spawn the entity because the entity comes with the model set and code. All I need to do is spawn it and set its angles and position. How would I do this? Any help is appreciated.
A good way is to make sure you have cl_showpos 1 in console.
This will give your vector pos and angles.
Put the name of the sent in the ents.Create
Also add dealer:DropToFloor() to make sure it's on the ground if you want.
[CODE]hook.Add( "Initialize", "EntityInit", function()
local dealer = ents.Create("scripted_entity")
dealer:SetPos(Vector(6573, 4321, 202))
dealer:SetAngles(Angle(0, 0, 0))
dealer:SetModel("models/Characters/Hostage_02.mdl")
dealer:SetSolid(SOLID_BBOX)
dealer:Spawn()
end)[/CODE]
Not tested, if it's wrong I'm sure someone will correct me :) Try that though.
You cannot use Initialize or it will crash the server. You have to use InitPostEntity
I know how to get the pos and all that but what I am confused about is like if its a already created entity in the spawn menu, how do I spawn that automatically. Since it already has the code and model all I would need to do is spawn it and set its position. How would I do that?
[QUOTE=Bkamahl;52525810]I know how to get the pos and all that but what I am confused about is like if its a already created entity in the spawn menu, how do I spawn that automatically. Since it already has the code and model all I would need to do is spawn it and set its position. How would I do that?[/QUOTE]
Exactly the same, just leave out SetModel and SetSolid
Ooooooh got it alright thanks guys :)
Sorry, you need to Log In to post a reply to this thread.