MP Random Spawn Locations

Place to get help with not working mods / modding interface.
tno1
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Tue Nov 11, 2014 1:12 am
Contact:

MP Random Spawn Locations

Post 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
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: MP Random Spawn Locations

Post by DaveMcW »

In map editor, make a custom scenario with 2 spawn points.
tno1
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Tue Nov 11, 2014 1:12 am
Contact:

Re: MP Random Spawn Locations

Post by tno1 »

That doesnt work :/

Atleast I dont find the Custom Scenario in the Multiplayer part :/
User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: MP Random Spawn Locations

Post 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
tno1
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Tue Nov 11, 2014 1:12 am
Contact:

Re: MP Random Spawn Locations

Post by tno1 »

Gonna try that :)
Thanks man :p
Post Reply

Return to “Modding help”