Page 1 of 1

How to get the "minPlayersToStartGame" value?

Posted: 12 Apr 2011, 16:52
by Sparticus
Hey all,

When creating a new game, I use these settings :

Code: Select all

 var settings:SFSGameSettings = new SFSGameSettings("foobar"+foo);
            settings.maxUsers = 4;
            settings.maxSpectators = 8;
            settings.isPublic = true;
            settings.minPlayersToStartGame = 2;
            settings.leaveLastJoinedRoom = true;
            settings.notifyGameStarted = true;


and I am able to do this to the room object :

Code: Select all

var maxUsers:Number = this.room.maxUsers;


and it works fine. However, this doens't even compile :

Code: Select all

var minPlayers:Number = this.room.minPlayersToStartGame;


it doesn't know that the "minPlayersToStartGame" variable is.

Any ideas?

Posted: 12 Apr 2011, 17:49
by Democre
It doesn't look like that is an exposed property. Maybe you could set your own room variable and use room.getVariable("...").getIntValue().

Posted: 12 Apr 2011, 18:00
by Sparticus
Ya....but then the question is, why is that one of the settings you can pass in if you can't even use it?

Posted: 12 Apr 2011, 18:14
by Democre
Good question. It looks like it is used in several areas of server logic. I don't know why it is hidden.

The docs wrote:minPlayersToStartGame: the minimum number of players to start the game. If the game is already running and the number of players goes below this limit the game will be stopped.

Although I am unclear as to what this really means. How does SFS start or stop a game? Is it just a flag being set or are there events we can hook?

Posted: 12 Apr 2011, 22:37
by Bax
[P4E]Andy wrote:Good question. It looks like it is used in several areas of server logic. I don't know why it is hidden.

The docs wrote:minPlayersToStartGame: the minimum number of players to start the game. If the game is already running and the number of players goes below this limit the game will be stopped.

Although I am unclear as to what this really means. How does SFS start or stop a game? Is it just a flag being set or are there events we can hook?

Check the SFSGameSettings.notifyGameStarted property description in the API doc.