I need my npc/entity to spawn or be placed on this vector
-6941.322754, -9302.659180, 136.031250
the name of the npc is: npc_shop
[lua]
hook.Add("InitPostEntity","PlaceShopNPC",function()
local pos = Vector(-6941.322754,-9302.659180,136.031250)
local angles = Angle(0,0,0)
local npc = ents.Create("npc_shop")
npc:SetPos(pos)
npc:SetAngles(angles)
npc:Spawn()
end)
[/lua]
Should work but untested.
You may want to edit the angles.
[QUOTE=zzaacckk;28121132][lua]
hook.Add("InitPostEntity","PlaceShopNPC",function()
local pos = Vector(-6941.322754,-9302.659180,136.031250)
local angles = Angle(0,0,0)
local npc = ents.Create("npc_shop")
npc:SetPos(pos)
npc:SetAngles(angles)
npc:Spawn()
end)
[/lua]
Should work but untested.
You may want to edit the angles.[/QUOTE]
were would i place that?
init.lua ?
Yup.
You better give some kind of credit to Facepunch Forums to help you make your RP.
Wonder what kind of RP it would be for this server without FP.
[QUOTE=Donkie;28128233]Wonder what kind of RP it would be for this server without FP.[/QUOTE]
It wouldn't be an RP. It would be sandbox.
[QUOTE=zzaacckk;28121132][lua]
hook.Add("InitPostEntity","PlaceShopNPC",function()
local pos = Vector(-6941.322754,-9302.659180,136.031250)
local angles = Angle(0,0,0)
local npc = ents.Create("npc_shop")
npc:SetPos(pos)
npc:SetAngles(angles)
npc:Spawn()
end)
[/lua]
Should work but untested.
You may want to edit the angles.[/QUOTE]
No.
[lua]
function SpawnNPCs()
local NPC = ents.Create("npc_shop");
NPC:SetPos(Vector((-6941, -9302, 136));
NPC:SetAngles(Angle(0, 0, 0)); -- Insert your angle. Take away the stuff that is after the "."
NPC:Spawn();
end
hook.Add( "InitPostEntity", "SpawnNPCs", SpawnNPCs)
[/lua]
100% working. Using this myself all the time.
Stick this in init.lua
[QUOTE=Crap-Head;28129779]No.
[lua]
function SpawnNPCs()
local NPC = ents.Create("npc_shop");
NPC:SetPos(Vector((-6941, -9302, 136));
NPC:SetAngles(Angle(0, 0, 0)); -- Insert your angle. Take away the stuff that is after the "."
NPC:Spawn();
end
hook.Add( "InitPostEntity", "SpawnNPCs", SpawnNPCs)
[/lua]
100% working. Using this myself all the time.
Stick this in init.lua[/QUOTE]
I see no problem with his? It's fine.
He posted the same exact thing I did except removed the pos and angle variables and just plugged them into his arguments instead.
Short: He posted the same thing I did, and said mine was wrong.
how do i add a chat bubble thing over its head now?
Wow I am bad at reading one sec.
[lua]
hook.Add("InitPostEntity","AddNPCThing",function()
timer.Create("AddNPCThing",2,1,function()
for a,b in pairs(ents.GetAll()) do
if (string.find(b:GetClass(),"npc_") == 1) && b:IsNPC() then
local q = b:GetPos()
local p = ents.Create("prop_physics")
p:SetModel("models/extras/info_speech.mdl")
p:SetPos(Vector(q.x,q.y,q.z+100))
p:SetMoveType(MOVETYPE_NONE)
p:Spawn()
p:GetPhysicsObject():EnableMotion(false)
end
end
end)
end)
[/lua]
Wont work if your NPC's move. You need to update them if thats the case.
[QUOTE=BananasRP;28121079]I need my npc/entity to spawn or be placed on this vector
-6941.322754, -9302.659180, 136.031250
the name of the npc is: npc_shop[/QUOTE]
ever thought of [url]http://wiki.garrysmod.com/[/url]?, but i guess "Getting hooks" is stealing Codes to you. :frog:
[IMG]http://i55.tinypic.com/30xaqtf.jpg[/IMG]
[IMG]http://i51.tinypic.com/25f5zs1.jpg[/IMG]
Sorry, you need to Log In to post a reply to this thread.