How to get the "minPlayersToStartGame" value?

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Sparticus
Posts: 217
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

How to get the "minPlayersToStartGame" value?

Postby Sparticus » 12 Apr 2011, 16:52

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?
Democre
Posts: 77
Joined: 16 Sep 2010, 17:58

Postby Democre » 12 Apr 2011, 17:49

It doesn't look like that is an exposed property. Maybe you could set your own room variable and use room.getVariable("...").getIntValue().
Sparticus
Posts: 217
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Postby Sparticus » 12 Apr 2011, 18:00

Ya....but then the question is, why is that one of the settings you can pass in if you can't even use it?
Democre
Posts: 77
Joined: 16 Sep 2010, 17:58

Postby Democre » 12 Apr 2011, 18:14

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?
User avatar
Bax
Site Admin
Posts: 4448
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 12 Apr 2011, 22:37

[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.
Paolo Bax
The SmartFoxServer Team

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 6 guests