set and update Roomvariables...

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

Moderators: Lapo, Bax

User avatar
JarochoCity
Posts: 181
Joined: 01 Dec 2005, 01:22
Location: Mexico
Contact:

set and update Roomvariables...

Postby JarochoCity » 02 Apr 2006, 23:22

i set the variables like this, is this ok?

Code: Select all

function actualizarsilla4() {
   var sillax4:Number = _root.silla4._x;
   var sillay4:Number = _root.silla4._y;
   var sillag4:Number = _root.silla4._currentFrame;
   vObj = new Array();
   vObj.push({sillag10:sillag10, sillax10:sillax10, sillay10:sillay10, persistent:true});
   smartfox.setRoomVariables(vObj);
   
}


And how can i update them? like this?

Code: Select all

smartfox.onRoomVariablesUpdate = function(roomObj:Room, changedVars:Object)
{
var rVars:Object = roomObj.getVariables();

sillavar4 = _root.silla4;
      sillavar4._x = rVars.sillax4;
      sillavar4._y = rVars.sillay4;
sillavar4.gotoAndStop(rVars.sillag4);




please answer! :D[/code]
User avatar
JarochoCity
Posts: 181
Joined: 01 Dec 2005, 01:22
Location: Mexico
Contact:

forget about the codes i put...i correct them but.. how.....

Postby JarochoCity » 03 Apr 2006, 00:10

forget about the codes i put, i correct them,

1- but i have put persistent:true and the variables go away when the one who creates them goes off the room, why??

2 - And how can i make a room thats stays for ever in the server??
User avatar
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Postby Virusescu » 03 Apr 2006, 06:17

Well
1. I'm guessing that the variables don't persist because you don't create persistent rooms and if the room get's destroyed when all users exit then so does all the variables attached.

You have 2 ways (from what I know) of creating persistent rooms.
1. From the config.xml file of the SFS server inside each zone you can add your rooms.
2. From within a server side extension with the createRoom() function. If you pass null as the user param, the server will own the room and the room will be made persistent.
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}
User avatar
JarochoCity
Posts: 181
Joined: 01 Dec 2005, 01:22
Location: Mexico
Contact:

ok...but

Postby JarochoCity » 03 Apr 2006, 19:47

1- no, when the owner exits the Room and there still people inside the room the variables get destroyed, or i need the 1.4.0 .... and i put the variables as persistent :? and it doesn't work, is the code OK like this:

Code: Select all

function actualizarsilla4() {
var sillax4:Number = _root.silla4._x;
var sillay4:Number = _root.silla4._y;
var sillag4:Number = _root.silla4._currentFrame;
var roomVar:Array = []
roomVar.push( {name:"sillax4", val:sillax4, priv:false, persistent:true} )
roomVar.push( {name:"sillay4", val:sillay4, priv:false, persistent:true} )
roomVar.push( {name:"sillag4", val:sillag4, priv:false, persistent:true} )
smartfox.setRoomVariables(roomVar)
}


2 - and how do i put the user param as NULL ??? And do i need the 1.4.0?

please answer :D
User avatar
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Postby Virusescu » 04 Apr 2006, 06:26

no. The code is NOT ok.
The SFS extensions work with AS1 sintax, not AS2.
Lines like var roomVar:Array = []; will probably get ignored, although I'm surprised that it didn't threw an error.

And yes, you need SFS 1.4.
In the documentations, each function has listed it's availability
for the setRoomVariables you have
Availability:
SmartFoxServer PRO 1.4.0


Hope this helps
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}
User avatar
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Postby Virusescu » 04 Apr 2006, 06:32

Sorry for the previous post.
I though you were trying to do this from an extension.
You can set roomVariables with any version of SFS, from the client side.

Your code seems ok.
Do the variables get listed if you use the admin console to inspect the room?
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}
User avatar
JarochoCity
Posts: 181
Joined: 01 Dec 2005, 01:22
Location: Mexico
Contact:

yes they get listed but.....

Postby JarochoCity » 04 Apr 2006, 17:21

Yes, they get listed but they don't get listed as persistent.. why??
And when the one who created the Variables exits the room, the variables disappear why??

AND I PUT persistent:true ! :? :? :?
User avatar
Lapo
Site Admin
Posts: 21116
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 04 Apr 2006, 19:42

1- no, when the owner exits the Room and there still people inside the room the variables get destroyed, or i need the 1.4.0 .... and i put the variables as persistent


Persistent variables exist until the user leaves the server. If you turn it off, your variables will be lost as soon as you leave the room.

If you don't want variables to be destroyed even when the user goes away, there are a number of ways to do it:

1 -> set the variables in your config.xml. This way they will be initially owned by the Server. When you call the setRoomVariables() method, specify the setOwnership flag to false (check the docs!)

2-> use server side extensions to have complete control over server variables.
Here's an older discussion that can help too
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
JarochoCity
Posts: 181
Joined: 01 Dec 2005, 01:22
Location: Mexico
Contact:

so the code should look like this..

Postby JarochoCity » 04 Apr 2006, 20:26

so the code should look like this.. right?

Code: Select all

var roomVar:Array = [];
roomVar.push({name:"rugx10", val:rugx10, priv:false, setOwnership:false});
roomVar.push({name:"rugy10", val:rugy10, priv:false, setOwnership:false});
roomVar.push({name:"rugg10", val:rugg10, priv:false, setOwnership:false});
smartfox.setRoomVariables(roomVar);


And the variable will never get destroyed unless someone delete the room right??
User avatar
JarochoCity
Posts: 181
Joined: 01 Dec 2005, 01:22
Location: Mexico
Contact:

i've donde that and still doesn't work!

Postby JarochoCity » 04 Apr 2006, 20:43

I have put the Variable:

Code: Select all

roomVar.push({name:"plasmax2", val:plasmax2, priv:false, setOwnership:false});


And still doesn't work!! the variables continue destroying!! when the User exits the server =S
User avatar
JarochoCity
Posts: 181
Joined: 01 Dec 2005, 01:22
Location: Mexico
Contact:

i have solved the problem...

Postby JarochoCity » 04 Apr 2006, 21:18

i have solved the problem i think there was a mistake in the "SmartFoxClient.as" it said:

Code: Select all

if (setOwnership)
var xmlMsg:String = "<vars>"
else
var xmlMsg:String = "<vars so='0'>"


And I changed like this: (LOOK AT THE "FALSE" THAT I PUT)

Code: Select all

if (setOwnership == false)
var xmlMsg:String = "<vars>"
else
var xmlMsg:String = "<vars so='0'>"


And it works like that i think i have found a bug :?

See you... i will upgrade the 1.4.0 so people can create Rooms that will stay for ever with their variables :D


--------------------------------
[red]JarochoCity[/red]
User avatar
JarochoCity
Posts: 181
Joined: 01 Dec 2005, 01:22
Location: Mexico
Contact:

wich files do i need to upgrade?

Postby JarochoCity » 04 Apr 2006, 22:36

1 - wich files do i need to upgrade to the 1.4.0 and where should I upgrade at the server, my .AS or what?

2 - and wich ones do i need to upgrade to make that when someone creates a room will never get deleted.
User avatar
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Postby Virusescu » 05 Apr 2006, 06:59

i have solved the problem i think there was a mistake in the "SmartFoxClient.as" ...

You are preety funny.
You search for bugs but you don't mind reading the docs with more attention :shock:
It's true that setOwnership seems to be a roomVariable property. But if you look at the usage of setRoomVariables method you will notice
smartFox.setRoomVariables(variables:Array, roomId:Number, setOwnership:Boolean);


The setOwnerShip flag, is, as you can see, a parameter of the method call and not a property of the roomVariable object you pass into the roomVariables array

As it defaults to true and you dindn't managed yet to set it to false, when the code execution reaches that functions inside the SFS propietary AS the setOwnership variable is true. All you did was not to solve a bug, but change the way that a roomVariable defaults when set.
Now it defaults to false, instead of true.

Well... maybe you did find a bug. But it's more like a missing <br> in the documentation

Good luck :wink:
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}
User avatar
Lapo
Site Admin
Posts: 21116
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 05 Apr 2006, 07:36

:lol: :lol: :lol:
JarochoCity,
you obviously didn't even spend one second reading the docs and the other discussion I posted.

It makes it quite hard to help you if every bit of information that is given is completely overlooked. :roll:

If I were you, I would restore the original API file :P ... and take a little time to READ the docs.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
JarochoCity
Posts: 181
Joined: 01 Dec 2005, 01:22
Location: Mexico
Contact:

yeah sorry...

Postby JarochoCity » 05 Apr 2006, 13:50

yeah sorry...

it's because i´m very busy and i try to find it and i cant! sorry :?

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 23 guests