Page 1 of 1
User Variables on Avatar Clothing
Posted: 24 Jan 2012, 00:09
by Bosskafett
Hi, I have been developing a multiplayer game with Ducks at
http://duckclub.sytes.net.
I have created a clothing engine but I am unsure on how to make the server see the current movie clip frame of the clothing. I have tried making user variables to make the clothing movie clip current frame visible on all screens.
Please help, all of the users want it to work properly and I have done all I can.
Thanks,
Jacko
Posted: 24 Jan 2012, 09:06
by Bax
You are on the right track: save a user variable identifying which clothes the avatar is using. When you enter a room and process the list of users to create their avatars, based on that user variable you can display the correct clothes.
Structure
Posted: 24 Jan 2012, 16:51
by Bosskafett
How exactly would I structure this? I have tried setting a user variable under "hd" and set it to a number 'var hd:Number' and made it equal the current frame of the head movieclip. 'var hd:Number = mc.duck.duck_3d.head._currentframe'.
Then 'smartfox.setUserVariables{(hd:hd, init=false)}'. Im not sure where to put this and what else to do... perhaps could you help me with what to put in and where.
Cheers, oh and thanks for getting back to me.

Posted: 25 Jan 2012, 08:27
by Bax
I'm sorry, but you will need to read the SFS documentation, as this is a very basic situation. Check the Avatar Chat example: if I remember correctly, the user variables are used to set the avatar color.
ok
Posted: 25 Jan 2012, 10:38
by Bosskafett
Ok I will check it out and get back to you
More help??
Posted: 25 Jan 2012, 10:47
by Bosskafett
Ok right, the variables should be updated when the button is clicked to change frame of the clothing movieclip. None of the other variables such as px and py or col, relate to what I a m trying to do. Its very confusing and the documentation dosent help much with the problem. As you said this is a simple situation so I am not to sure on how to get all this to work. I have tried everything I can. Please help me

Posted: 26 Jan 2012, 07:38
by Bax
I don't understand. The col variable works very similarly.
Anyway, when you create the users avatars after joining the room, you have to check their user variables and read the value you updated.
yes
Posted: 26 Jan 2012, 21:32
by Bosskafett
Yeah I managed to figure it out. The only problem is that it dosent update that variable unless you rejoin the room or a new user logs in. If you made the changes in a room at the same time someone else was there, they see no changes...
Is there something extra I need to put into the onUpdateVariables function?
Reminder that I built upon col so thats designed for room joining updates so its not.. live... if you get me.
Any suggestions?
Thanks

Posted: 27 Jan 2012, 09:06
by Bax
You have three separate cases you have to handle, listening to the appropriate SFS events:
1) you enter a room: all users already in that room are notified; they must read your User Variables and create your avatar on their clients accordingly
2) a client enters the room you joined previously: it receives the list of users inside that room, reads their UV and create their avatars accordingly
3) you are inside a room and make changes to your UV: all the other clients inside that room receive an event informing them that your UV has/have been updated, and should change your avatar appearance accordingly.
Check out my code
Posted: 27 Jan 2012, 19:35
by Bosskafett
.: Please advise me on making this current room update work, heres the function :.
smartfox.onUserVariablesUpdate = function(user:User)
{
var currRoom:Number = this.getActiveRoom()
var id:Number = user.getId()
var uVars:Object = user.getVariables()
var mc:MovieClip
if (uVars.init)
{
mc = avatarMC.attachMovie("avatar", "avatar_" + id, Number(id))
mc._x = uVars.px
mc._y = uVars.py
mc.duck.duck_3d.head.gotoAndStop(uVars.hd)
mc.duck.duck_3d.gotoAndStop(uVars.xc)
mc.disc.gotoAndStop(uVars.col)
mc.name.text = user.getName()
}
else
{
mc = avatarMC["avatar_" + id]
mc.easingTo("Quint", "InOut", uVars.px, uVars.py, 100)
}
}
Posted: 28 Jan 2012, 10:24
by Bax
This is not the way you retrieve variables. Please check the API documentation, you will find an example in the onUserVariablesUpdate event description.
thanks
Posted: 30 Jan 2012, 07:44
by Bosskafett
thanks for helping, I already figured this out. The variables now update properly.
Cheers Bax