Page 1 of 1

Delete a player from the Server

Posted: Sun Jun 24, 2018 9:13 am
by doppelEben
Hi there

We are currently facing the problem, that one player misses his armor. And due to high-tech-start with bots, we arent on the point we can reproduce the armor easily(much higher tier). So I am looking for a way to "delete" him from the server so that he can join again and is handled as a new user, with all the starting-stuff. Is there any lua-command or file I can delete to 'delete the user from the server' ?

best regards,
doppelEben

Re: Delete a player from the Server

Posted: Sun Jun 24, 2018 7:18 pm
by Jap2.0
Can you upload a save for me to poke around in?

Re: Delete a player from the Server

Posted: Sun Jun 24, 2018 8:00 pm
by doppelEben

Re: Delete a player from the Server

Posted: Sun Jun 24, 2018 11:15 pm
by Nexela

Code: Select all

/c game.remove_offline_players(game.players["Padde"].index)
or (this should work and keep all other earned stats)

Code: Select all

/c game.raise_event(defines.event.on_player_created, {player_index = game.players["Padde"].index})
Because of mods both of these "could" have bad behaviours depending on what other mods do re on_player_created

Re: Delete a player from the Server

Posted: Sun Jun 24, 2018 11:26 pm
by eradicator
What i've used before in a similar situation is:

Code: Select all

/c game.players['Padde'].get_inventory(defines.inventory.player_armor)[1].set_stack(game.player.get_inventory(defines.inventory.player_armor)[1])
This will place an exact copy of the armor of the person typing the command into 'Padde's armor slot. The armor currently in his slot will be destroyed, so tell him to take it out if it's important.

Here's a more generic version that will copy the cursor item to other players in case you need to retrieve other stuff.

Code: Select all

/c
local player1='YourName'
local player2='TheirName'
game.players[player1].cursor_stack.set_stack(game.players[player2].cursor_stack)

Re: Delete a player from the Server

Posted: Mon Jun 25, 2018 12:58 am
by Zavian
A simpler solution might be to find a friend who isn't going to play. Have them join, dump their new armour in a box, and then leave. (This isn't very scalable but it avoids the need for console commands). If you can probably fake that by turning off authentication in the server setup, and having an existing player temporarily change his in his factorio name in settings. (The host could probably also do that by changing his name, and loading the map in single player between sessions).

Re: Delete a player from the Server

Posted: Mon Jun 25, 2018 7:24 am
by darkfrei
You can also add the same code to the on_player_respawned like in on_player_created.

Re: Delete a player from the Server

Posted: Mon Jun 25, 2018 7:20 pm
by doppelEben
Nexela wrote:

Code: Select all

/c game.remove_offline_players(game.players["Padde"].index)
or (this should work and keep all other earned stats)

Code: Select all

/c game.raise_event(defines.event.on_player_created, {player_index = game.players["Padde"].index})
Because of mods both of these "could" have bad behaviours depending on what other mods do re on_player_created
eradicator wrote:What i've used before in a similar situation is:

Code: Select all

/c game.players['Padde'].get_inventory(defines.inventory.player_armor)[1].set_stack(game.player.get_inventory(defines.inventory.player_armor)[1])
This will place an exact copy of the armor of the person typing the command into 'Padde's armor slot. The armor currently in his slot will be destroyed, so tell him to take it out if it's important.

Here's a more generic version that will copy the cursor item to other players in case you need to retrieve other stuff.

Code: Select all

/c
local player1='YourName'
local player2='TheirName'
game.players[player1].cursor_stack.set_stack(game.players[player2].cursor_stack)
thanks for the tipps guys. will write that down if another time the armor says bye :)
Zavian wrote:A simpler solution might be to find a friend who isn't going to play. Have them join, dump their new armour in a box, and then leave. (This isn't very scalable but it avoids the need for console commands). If you can probably fake that by turning off authentication in the server setup, and having an existing player temporarily change his in his factorio name in settings. (The host could probably also do that by changing his name, and loading the map in single player between sessions).
Thats what we did in the end. The new user dropped his starting-equip in a chest and "padde" could grab it from there.