I've been trying to script some npcs for my gamemode that spawn as shops on the map when the game and server start up.
Can anyone help me with this? i've tried scripting it using the ingfo i found off trying to search it up in google. none of them work. :/ So can someone help me with this issue? perhaps show me a full working example of an npc shop that spawns on server startup?
I've already seen that. I understand that much but it still doesn't explain how to place it on the on start :/ Any ideas on how to help with that?
[LUA]
function SpawnNPC(Classname)
local NPC=ents.Create(Classname)
NPC:SetPos(Vector(x, y, z))
NPC:Spawn()
end
hook.Add("InitPostEntity","SpawnNPC",function() SpawnNPC("npc_shop") end -- Replace npc_shop with your npcs classname.
[/LUA]
Type getpos in console for the X, Y, and Z coordinates
In the init.lua file, add this:
[lua]
function SpawnNPCs()
local NPC = ents.Create("ent_name_here");
NPC:SetPos(Vector( 890, -515, 79 )); --Vector( x, y, z )
NPC:SetAngles(Angle(0, -180, 0));
NPC:Spawn();
end
hook.Add( "InitPostEntity", "spawnnpcs", SpawnNPCs)[/lua]
To get the pos in the map, go to the pos in the map where you want the NPC, and type getpos in console. It then displays the X, Y, and Z coordinates in which you use for Vector().
Edit: Lua Noob beat me to it. D:
But you solved his and my problem thanks!
Sorry, you need to Log In to post a reply to this thread.