game.is_multiplayer required
game.is_multiplayer required
Because I'm working on a permission system, i'd like to let the people who load saves from singleplayer have admin and all permissions. Is that possible?
Re: game.is_multiplayer required
Loading a save from single player already has the player as an admin.
If you want to get ahold of me I'm almost always on Discord.
Re: game.is_multiplayer required
As my test, loading a multiplayer game at singleplayer would not give the player admin permission, for he can't run /permissions.
edit:
The player had been added to a permission group already.
edit:
The player had been added to a permission group already.
Re: game.is_multiplayer required
That's not what you said - you said loading single player games in multiplayer.acabin wrote:As my test, loading a multiplayer game at singleplayer would not give the player admin permission, for he can't run /permissions.
edit:
The player had been added to a permission group already.
If you want to get ahold of me I'm almost always on Discord.
Re: game.is_multiplayer required
It looks like my pool English leads to some misunderstood. I'll describe what I am doing:Rseding91 wrote: That's not what you said - you said loading single player games in multiplayer.
1. Start a new game in MP
2. With the host's settings, my mod will move some players to a 'guest' group, which nearly can't do anything
3. If a 'guest' want to play the map offline, he will start a singleplayer game and load the save
4. In that case, I want to give the 'guest' all permissions and the player.admin flag
Now the problem:
I can't detect if the player is playing singleplayer or he is the only online player in a headless server.
So, I want a game.is_multiplayer or script.is_multiplayer flag or a way to check.
Re: game.is_multiplayer required
Is there any update?
Re: game.is_multiplayer required
I see.acabin wrote:It looks like my pool English leads to some misunderstood. I'll describe what I am doing:Rseding91 wrote: That's not what you said - you said loading single player games in multiplayer.
1. Start a new game in MP
2. With the host's settings, my mod will move some players to a 'guest' group, which nearly can't do anything
3. If a 'guest' want to play the map offline, he will start a singleplayer game and load the save
4. In that case, I want to give the 'guest' all permissions and the player.admin flag
Now the problem:
I can't detect if the player is playing singleplayer or he is the only online player in a headless server.
So, I want a game.is_multiplayer or script.is_multiplayer flag or a way to check.
Unfortunately that's not going to be possible. That information isn't deterministic - the best you can do is detect if #game.players is > 1 but that's still not going to do it fully.
If you want to get ahold of me I'm almost always on Discord.
Re: game.is_multiplayer required
You could try something along the lines of (edit: the desync bilka warned about doesn't happen, but his instincts are good, fixed a lesser desync. but this stsill doesn't work: it appears on_player_joined _does_ fire in singleplayer loads of saved multiplayer maps. Oh, well.)
nope-doesnt-work
Last edited by quyxkh on Mon Feb 05, 2018 9:18 am, edited 1 time in total.
Re: game.is_multiplayer required
That's a fast and easy way to produce desyncs, congratulations. It should start desyncing on join after the second person joined, for the person that is joining. The person will be stuck in a desync loop and unable to ever join, unless the server is restarted and the person joins as the first person.quyxkh wrote:You could try something along the lines ofCode: Select all
joined_this_session = {} -- control.lua gets rerun for each map init/load script.on_event(defines.events.on_player_joined_game,function(ev) joined_this_session[ev.player_index]=true end) -- setup so `/makemeaboss` in sp mode works right function makemeaboss(cparms) if not joined_this_session[cparms.player_index] then -- your grant-boss-powers code here else game.print(game.players[cparms.player_index].name..' wants to be a boss.') end end commands.add_command('makemeaboss',{'','use the source'},makemeaboss)
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: game.is_multiplayer required
Testing shows it doesn't desync on load, it desyncs when a second player joins and the first player tries the command, because the second player wasn't there for the first player's join event. I fixed that by loading up the context when the client sees its first join event, I can't make it desync now.
But that doesn't help, because loading a save of an mp map in singleplayer mode fires on_player_joined_game anyway.
Anybody _really_ desperate to do this can just edit the mod locally.
But that doesn't help, because loading a save of an mp map in singleplayer mode fires on_player_joined_game anyway.
Anybody _really_ desperate to do this can just edit the mod locally.