• Entity not spawning on server start?
    2 replies, posted
I have made a script and put it into my lua/autorun/server/ with the contents: [lua] hook.Add("InitPostEntity", "initMother", function() print("spkoaspkopoasfkopfkopfaopkopksafkopaffokpaskopfakopskoapkospafokpsaopksakopfkofpaskopasfkofpashi hi bai") -- This appears local space = ents.Create("garage") space:SetPos(Vector(1023, 1013, 181)) space:SetAngles(Angle(0,-180 + 180, 0)) space:SetModel("models/hunter/plates/plate2x4.mdl") space:Spawn() space:Activate() end) [/lua] For some reason, the entity does NOT spawn at all. No errors or anything, it just doesnt spawn. [editline]23rd April 2014[/editline] Correction: It does spawn but for some reason it doesnt spawn exactly in the vector I told it to. For example, I could teleport to 1023, 1013, 181 and it not be there but fly around the map and eventually find it in some random place about 39423984923840 miles away from where I set it... Wtf?
have you try spawning something else with that code ?? [editline]23rd April 2014[/editline] this is why [lua] Crazy physics on [70][sent_ball] [Ang:-1.#IND00,1.#QNAN0,180.000000] [Pos:-1869.697998,-1269.767456,15.720802] - removing [/lua] [editline]23rd April 2014[/editline] This worked for me when I set a timer so I guess it could be that it is spawning to early or its something to do with the entity your trying to spawn . it did not worked when I used sent_ball [lua]hook.Add("InitPostEntity", "initMother", function() timer.Simple(10,function() print("spkoaspkopoasfkopfkopfaopkopksafkopaffokpaskopfakopskoapkospafokpsaopksakopfkofpaskopasfkofpashi hi bai") -- This appears local space = ents.Create("prop_physics") space:SetPos(Vector(-1869.697998, -1269.767456 ,16.122902)) //space:SetAngles(Angle(0,-180 + 180, 0)) space:SetModel("models/hunter/plates/plate2x4.mdl") space:Spawn() space:Activate() end) end)[/lua]
You may want to freeze or weld the prop to the world when you spawn it to prevent it moving. That's how I spawn all of my map additions.
Sorry, you need to Log In to post a reply to this thread.