persistenting var help

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

Post Reply
-Fantastic-
Posts: 9
Joined: 01 May 2010, 00:34
Location: itsNONEOFURBISSOKAY AV

persistenting var help

Post by -Fantastic- »

I Can't see my error
<Var name="lev" type="n" private="true"/></Var>
Help?
Stick Figure Fighting Maker

Dennis Los Tejada
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post by BigFIsh »

Navigate to chapter 4 of http://www.smartfoxserver.com/docs/ and select your API and look for setRoomVariables method.
Smartfox's forum is my daily newspaper.
-Fantastic-
Posts: 9
Joined: 01 May 2010, 00:34
Location: itsNONEOFURBISSOKAY AV

Post by -Fantastic- »

BigFIsh wrote:Navigate to chapter 4 of http://www.smartfoxserver.com/docs/ and select your API and look for setRoomVariables method.

I Don't understand What Am I doing wrong.
function createRoom(name, pwd, spec)
{
hideWindow("newGameWindow")
BotControlling = true
var rVars:Array = new Array()
rVars.push({name:"score", val:2500, persistent:true})
smartFox.setRoomVariables(rVars)

var gameRoom:Object = new Object()
gameRoom.name = name
gameRoom.password = pwd
gameRoom.maxUsers = _root.MaxPlayers
gameRoom.isGame = true
gameRoom.isTemp = true
gameRoom.vars = [];
gameRoom.vars.push({name: "level", val:5, persistent: true});
smartfox.createRoom(gameRoom)
}

smartFox.onRoomVariablesUpdate = function(roomObj:Object){
_root.tesst.text = roomObj.getVariable("kill");
}
smartfox.onJoinRoom = function(roomObj)
{

if (roomObj.isGame()){
_root.tesst.text = roomObj.getVariable("level")
gotoAndStop("game");
}
}
Stick Figure Fighting Maker

Dennis Los Tejada
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post by BigFIsh »

Assuming your API is AS3, there is an example how to set the room variable properly: http://www.smartfoxserver.com/docs/docP ... mVariables
Smartfox's forum is my daily newspaper.
Post Reply