ok and what if i dont want a random spawn and i have a place on the map where i want to spawn how do i know the coords (x,y,z) of that point? and how would i write it with this hook?
ents.FindByClass( "" )
the wiki doesnt explain examples very well =/
Take a look at this sent - [url]http://toybox.garrysmod.com/ingame/?view=351&tab=code[/url]
It changes the players spawn to the sents current location
ents.FindByClass is used to find certain things so if prop_physics was put in the parameters you can use a for loop to go through all the props in the map and make them preform a function
[QUOTE=iTeehee;29439219]ok and what if i dont want a random spawn and i have a place on the map where i want to spawn how do i know the coords (x,y,z) of that point? and how would i write it with this hook?
ents.FindByClass( "" )
the wiki doesnt explain examples very well =/[/QUOTE]
Make a ent called ent_spawnpos or something then do
in players spawn
[lua]
local spawns = ents.FindByClass("ent_spawnpos")
player:SetPos(table.Random(spawns):GetPos())
[/lua]
now you might want to make a table at one point and remove the values as players spawn to prevent players from spawning in each other but this should start you off.
[QUOTE=faceguydb;29444763]Make a ent called ent_spawnpos or something then do
in players spawn
[lua]
local spawns = ents.FindByClass("ent_spawnpos")
player:SetPos(table.Random(spawns):GetPos())
[/lua]
now you might want to make a table at one point and remove the values as players spawn to prevent players from spawning in each other but this should start you off.[/QUOTE]
if you put
[lua]
local spawns = ents.FindByClass("prop_physics")
player:SetPos(table.Random(spawns):GetPos())
[/lua]
then you would spawn on a random prop that is in the world
as:
[Lua] local spawns = ents.FindByClass("what ever you want") [/Lua] Will create a table called spawns
and [Lua] table.Radom(spawns) [/Lua] Will pick a random value from that table
Very good break down sweeneypaul.
Ok.. what the fuck is this. Why are you using ents just to set a spawn position? You can use static positions because they don't need to be positions in a vmf..
OP: You can use player:GetPos() and player:GetAngles() to get a vector position and angle angle. You can also use "getpos" in the console.
I can't quite remember if PlayerSelectSpawn takes an entity or a vector as a return value. If it's a vector, you can just return the position. If not, hook to PlayerSpawn and player:SetPos and player:SetAngles to set them to the new spawn position.
[QUOTE=sweeneypaul;29444818]if you put
[lua]
local spawns = ents.FindByClass("prop_physics")
player:SetPos(table.Random(spawns):GetPos())
[/lua]
[/quote]
You would actually spawn [b]in[/b] the prop..
It was just an example of something similar and I know you would spawn in a prop but im sure he could figure out a fix like getting the bounding box length and add that to the z value of the spawn pos. Im only gave him some help if I wanted to write out exactly what he needed it might as well be in the request section
I don't know if this is related, but how can one make it to when you spawn in the player enters the vehicle on its ent spawn
[editline]31st August 2014[/editline]
I have a menu in which you select a plane, and I need the player to enter the vehicle when that plane spawns
Sorry, you need to Log In to post a reply to this thread.