Let say I create a map in SP with player binbin2, in order to use it in MP.
Then I run it on a headless server, whose name is binbin0
Then I connect with a different normal player called binbin1.
If I have this simple mod :
Code: Select all
script.on_event(defines.events.on_player_created,
function(event)
local player1 = game.players[event.player_index]
local player2 = game.get_player(event.player_index)
player1.print( "on_player_created " .. player1.name .. "=" .. tostring(player1.connected) .. " " .. player2.name .. "=" .. tostring(player2.connected) )
player2.print( "on_player_created " .. player1.name .. "=" .. tostring(player1.connected) .. " " .. player2.name .. "=" .. tostring(player2.connected) )
end
)
the first print gives nothing on console.
the second print gives :
Binbin2 = false Binbin1 = true
player1 and player2 are not the same !
So game.players refers to the old connected player that is offline...
But they should have disctinct index, no ?
Then if I connect the MP game with binbin2, I have a normal reconnexion, with no player_created.
I had such a long time finding this one !
