This is my code:
Code: Select all
local function onPlayerJoin(event)
print("on join called")
local force = nil
for force_index = 1, #game.forces do
if game.forces[force_index ].name == "test" then
force = game.forces[force_index]
end
end
if force == nil then
force = game.create_force("test")
end
game.players[event.player_index].force = force
end
EDIT:
Here is what the output on my console look like:
Code: Select all
2023-09-13 23:13:39 [JOIN] AaronVB joined the game
2023-09-13 23:13:44 [COMMAND] AaronVB (command): print(tostring(game.get_player("AaronVB").force.name))
player
2023-09-13 23:14:47 [LEAVE] AaronVB left the game
2023-09-13 23:14:48 [JOIN] AaronVB joined the game
2023-09-13 23:14:53 [COMMAND] AaronVB (command): print(tostring(game.get_player("AaronVB").force.name))
1