question about setUserVariables() in server

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Guest

question about setUserVariables() in server

Postby Guest » 02 Feb 2006, 02:58

Hi Lapo,

I have a problem in setting user variables in server side extension.

Code: Select all

function handleInternalEvent(evt) {
    var cmd = evt.name;
   if (cmd == "userJoin") {
   var u = evt.user;
   if (u.getVariable("fj")!=false) {
      //
      var uva = [];
      uva.push({name:"fj",val:false});
      _server.setUserVariables(u, uva);
      trace("variable "+ u.getVariable("fj"));
       }
   }
}

I want to make user to do someting only once when the user
join the room at first time.
But the result of trace function is null .
why?
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 02 Feb 2006, 14:33

Hi,
thanks for spotting this, there's an error in the docs for the beta 1.4

Actually your code would look like this:

Code: Select all

function handleInternalEvent(evt)
{
   var cmd = evt.name
   
   if (cmd == "userJoin")
   {
      var u = evt.user;
      trace("User joined: " + u.getName())
      
      if (u.getVariable("fj") != false)
      {
         //
         var uva = [];
         uva.fj = true
         
         _server.setUserVariables(u, uva);
         trace("fj :"+ u.getVariable("fj").getValue());
      }
   }
}


In other words you need to only pass an object with the properties you want to set. I've updated the docs with the correct version

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 28 guests