Page 1 of 1
welcome message on player joined game
Posted: Mon Oct 20, 2025 5:04 pm
by Blood Angel
I want to send "welcome message" then player joins to the server like 'no one will survive' or something like this.
google says that I may add it to lua
I've changed data/base/script/freeplay/control.lua on server side
Code: Select all
-- The script runs on the on_player_joined_game event
script.on_event(defines.events.on_player_joined_game, function(event)
local player = game.players[event.player_index]
game.print({"no one will survive", player.name})
end)
but when I try to connect, I get error
Code: Select all
Cannot join. The following mod script files are not identical between you and the server:
level
in this case I'll have to manually sync control.lua with all players. sad thing. maybe there's another way to create server side script without syncing it with players?
Re: welcome message on player joined game
Posted: Mon Oct 20, 2025 6:08 pm
by Atraps003
Create a new scenario on the server instead of modifying data/base/script/freeplay/
You can copy control.lua and freeplay.lua from data/base/script/freeplay/
scenarios/my-scenario/info.json
scenarios/my-scenario/description.json
scenarios/my-scenario/control.lua
scenarios/my-scenario/freeplay.lua
Then you load the scenario on headless server with this.
./bin/x64/factorio --start-server-load-scenario "my-scenario" --server-settings ./data/server-settings.json --map-gen-settings ./data/map-gen-settings.json --map-settings ./data/map-settings.json
Re: welcome message on player joined game
Posted: Mon Oct 20, 2025 7:04 pm
by Blood Angel
Atraps003 wrote: Mon Oct 20, 2025 6:08 pm
Create a new scenario on the server instead of modifying data/base/script/freeplay/
thank you. it works now

- 10-20-2025, 21-52-38.png (171.57 KiB) Viewed 170 times
cat data/base/scenarios/my-scenario/control.lua
Code: Select all
local handler = require("event_handler")
handler.add_lib(require("freeplay"))
if script.active_mods["space-age"] then
handler.add_lib(require("space-finish-script"))
else
handler.add_lib(require("silo-script"))
end
-- The script runs on the on_player_joined_game event
script.on_event(defines.events.on_player_joined_game, function(event)
local player = game.players[event.player_index]
game.print("no one will survive", {player.name})
end)
I'm not sure if the message will be shown to all active players or just those who have connected.
also the question: is it possible pop-up message instead of chat like this:

- 62mczdj88a7a1.png (432.41 KiB) Viewed 170 times
Re: welcome message on player joined game
Posted: Tue Oct 21, 2025 9:46 am
by Blood Angel
If i create custom scenario, there are no achievements.
in this case, I created new default game, unzip save file, added script to control.lua and zip it again, start server with modified save. and "welcome message" works.
Re: welcome message on player joined game
Posted: Tue Oct 21, 2025 1:10 pm
by Osmo
Blood Angel wrote: Mon Oct 20, 2025 7:04 pm
I'm not sure if the message will be shown to all active players or just those who have connected.
Since you use game.print, it will print the message to all players. Use player.print if you want to print a message for a specific player.
Blood Angel wrote: Mon Oct 20, 2025 7:04 pm
also the question: is it possible pop-up message instead of chat like this:
62mczdj88a7a1.png
You'll have to create a gui for it and handle events for when the window is confirmed or button is pressed and close the window.