Alright so I am somewhat familiar with Lua. I'm making a game mode and I want to includ the spawning of combine soldiers near the spawn of the players. I had asked a friend and he had no idea and google didn't help. Can any help me out?
Thanks,
Boom
Ok, I looked up more on this, and here you go.
[code]
nonplayer = ents.Create("npc_metropolice")
nonplayer:SetPos(Vector(0, 0, 0))
nonplayer:Spawn()
[/code]
Make sure to change the vector to the coords that you want to npc to spawn in (just put a wire gps there and read it's output)
Here is a list of all the different npc entity types:
[url]http://wiki.garrysmod.com/?title=List_of_Entities#NPC[/url]
I found that the npcs were actually entities, and since I already knew how to spawn entities, here you go!
[QUOTE=c0baltha1l;24148907](just put a wire gps there and read it's output)[/QUOTE]
Ew. No offense, but not everyone is using wire. Here are is a better way that works for everyone:
Console command:
[code]
lua_run print(player.FindByID(1):GetPos())
or
lua_run_cl print(LocalPlayer():GetPos())
[/code]
99% of people use wire, and that's the easiest way
[QUOTE=c0baltha1l;24154523]99% of people use wire, and that's the easiest way[/QUOTE]
No it aint. How would you spawn a NPC next to you, using wire, when pressing a DermaButton?
I meant get the vector from the gps (like write it down on a piece of paper) and enter that in the npcs spawn vector.
I have never used wire and probably never will, but that's not the point.
If you are going to suggest a way of getting a player's position, you should not tell him to "write it down on a piece of paper" after "getting the vector from the gps".
That's like saying: "I need a copy of this text; lets print it and scan it!"
EDIT: There is even a console command that prints the player's position immediately, but I forget what it is.
Ok, obviously nobody here is understanding me. What I am saying is a FIXED SPAWN LOCATION at THE SAME COORDS. The gps is to GET THOSE COORDS ONCE TO WRITE IN THE CODE
Why not just use the command
[code]getpos[/code]
It is much faster then setting up a GPS, and you don't need any experience in wire to do it...
No offense, but the random capitalizing of words does not help to get your point across. How about you just stand in the place where you want to spawn the npc, run the console command and copy the coordinates. You don't need wire / gps for that. Ever.
EDIT: Thanks LuckyLuke, that's the command I was trying to remember last post.
Fine, just to make the rest of you happy, this code when run (clientside) will spawn a combine close to where you are standing:
[code]
local playerVec = LocalPlayer():GetPos()
local npcRawVec = Vector(10, 0, 0)
local npcSpawnVec = playerVec:Add(npcRawVec)
nonplayer = ents.Create("npc_metropolice")
nonplayer:SetPos(npcSpawnVec)
nonplayer:Spawn()
[/code]
That's not what we were saying, but ok.
[QUOTE=c0baltha1l;24156623]Ok, obviously nobody here is understanding me. What I am saying is a FIXED SPAWN LOCATION at THE SAME COORDS. The gps is to GET THOSE COORDS ONCE TO WRITE IN THE CODE[/QUOTE]
Obviously, you dont understand us; What you're doing, is retarded. Just type GetPos in console to get both cordinates and angles.
Fixed location:
[code]npc:SetPos(Vector(x,y,z))[/code]
At player:
[code]npc:SetPos(ply:GetPos() + Vector(x,y,z))[/code]
That is exactly what I just did...
Sorry, you need to Log In to post a reply to this thread.