View Full Version : userVariable on demand?
niclas
09-10-2004, 01:22 PM
Hey,
I'm now using 'es.userVariableUpdated' to get to all userVariables as and when they're updated. Is there a way of loading them when the user requests the information instead? Or is there no gain in loading these less often?
Thanks (Jobe :),
Niclas
jobem
09-10-2004, 07:12 PM
Hi Niclas,
User variables are known if the user is known. So, if you have a user list then you already have access to every user's user variables in that list. es.userVariableUpdated will only be fired if one of those users creates or updates an existing user variable.
I hope I have understood your question.
niclas
09-12-2004, 07:24 PM
Brilliant, that's all I wanted to know!
Cheers,
Nic
niclas
09-15-2004, 02:54 PM
Hi again, I've now got it working... sort of. First let me post the code I use, firstly to set the user variables and secondly to retreive them when 'userListUpdated' is fired:
function setUserVars(){
es.createUserVariable("gamesWon", random(100));
es.createUserVariable("gamesLost", random(100));
es.createUserVariable("rating", random(4)+1);
}
setUserVars();
function populateUserList(userList,type,name){
userList = new Array();
var obUserList:Object = es.getUserList();
arrUserList = new Array();
for (var i=0; i<obUserList.length; i++) {
var user:Array = obUserList[ i ];
var username:String = user.Name.value;
if(username <> localUserName){
var ob:Object = new Object();
ob.gamesLost = user.userVariables.gamesLost;
ob.gamesWon = user.userVariables.gamesWon;
ob.rating = user.userVariables.rating;
ob.label = username + " (" + ob.rating + ")";
ob.data = username;
arrUserList.push(ob);
}
}
comUserlist.dataProvider = arrUserList;
}
es.userListUpdated = populateUserList;
The scenario seems to be as follows:
- When new players join the server, they can retrieve all the user variables from other players in that room
- When a player joins a new room they can retrieve all the user variables from other players in that room
- When a player joins your room, the user variables come up 'undefined'
The user names always show correctly, which means that part has been retreived, but not the user variables.
Can someone shed light on this issue? Thanks to all the ES gurus out there.
Regards,
Niclas
www.miniclip.com
niclas
11-09-2004, 04:45 PM
Hi,
I'm still experiencing this problem, are there any workarounds? I'm now running ES 3.6.4.
Cheers,
Niclas
jobem
11-10-2004, 08:20 PM
Hi Niclas,
You are running ES 3.6.4, but are you using the latest AS class file? If it is the AS 1 file then it will be 40.3 kb and inside it says the last edit date was 10/15/2004.
If it is the AS 2 file, then it will be 39.4kb and have a last edit date of 10/15/2004.
jobem
11-11-2004, 09:33 AM
Hi Niclas,
After testing your source files I sent you an email. There was a client side issue in your code. Along the way I found an unrelated user variable bug that I fixed too. Let me know if you have anymore questions!
niclas
11-11-2004, 03:06 PM
Hey Jobe,
Just one word: superb
Now the uservariables work like a dream, thanks very much for your help!
For people reading this having similar problems, instead of using:
es.userListUpdated = showUserVariables;
You should use:
es.userVariableUpdated = showUserVariables;
To ensure the user variables are shown when they are fully loaded.
Niclas
www.miniclip.com
Powered by vBulletin® Version 4.1.6 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.