Page 1 of 1
MP Random Spawn Locations
Posted: Tue Nov 25, 2014 10:04 pm
by tno1
Hello
So I was wondering if it was possible to let people automatically spawn at different locations?
So instead of everyone spawning at the same place then have people be moving to like 1500 tiles away
Fx Player 1 spawns at : 1515
and player 2 will then spawn at 3015
Regards
Re: MP Random Spawn Locations
Posted: Tue Nov 25, 2014 10:21 pm
by DaveMcW
In map editor, make a custom scenario with 2 spawn points.
Re: MP Random Spawn Locations
Posted: Tue Nov 25, 2014 10:53 pm
by tno1
That doesnt work :/
Atleast I dont find the Custom Scenario in the Multiplayer part :/
Re: MP Random Spawn Locations
Posted: Tue Nov 25, 2014 11:24 pm
by L0771
Code: Select all
game.onevent(defines.events.onplayercreated,function(event)
local player = game.getplayer(event.playerindex)
local positionX = math.random(1000,1500)
local positionY = math.random(1000,1500)
local position = game.findnoncollidingposition("player", {positionX,positionY}, 50, 1)
if position ~= nil then player.teleport(position) end
end)
I don't tried this but may work.
First browses position X and Y between 1000 and 1500, after browses a location where player can be teleport
EDIT: must use util.distance(pos1,pos2) to browse others players and spawn at Z of distance one to other one
Re: MP Random Spawn Locations
Posted: Tue Nov 25, 2014 11:33 pm
by tno1
Gonna try that
Thanks man :p