User Variables on Avatar Clothing

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

Moderators: Lapo, Bax

Post Reply
Bosskafett
Posts: 41
Joined: 24 Jan 2012, 00:04

User Variables on Avatar Clothing

Post 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
if(_global.is_rocketsnail == 1){
mc.snail._visible = true;
smartfox.setUserVariables({snl:1, init:false})
}
The Re-creator of Old Games ;D
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post 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.
Paolo Bax
The SmartFoxServer Team
Bosskafett
Posts: 41
Joined: 24 Jan 2012, 00:04

Structure

Post 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. :D
if(_global.is_rocketsnail == 1){
mc.snail._visible = true;
smartfox.setUserVariables({snl:1, init:false})
}
The Re-creator of Old Games ;D
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post 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.
Paolo Bax
The SmartFoxServer Team
Bosskafett
Posts: 41
Joined: 24 Jan 2012, 00:04

ok

Post by Bosskafett »

Ok I will check it out and get back to you
if(_global.is_rocketsnail == 1){
mc.snail._visible = true;
smartfox.setUserVariables({snl:1, init:false})
}
The Re-creator of Old Games ;D
Bosskafett
Posts: 41
Joined: 24 Jan 2012, 00:04

More help??

Post 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 :cry:
if(_global.is_rocketsnail == 1){
mc.snail._visible = true;
smartfox.setUserVariables({snl:1, init:false})
}
The Re-creator of Old Games ;D
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post 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.
Paolo Bax
The SmartFoxServer Team
Bosskafett
Posts: 41
Joined: 24 Jan 2012, 00:04

yes

Post 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 :?
if(_global.is_rocketsnail == 1){
mc.snail._visible = true;
smartfox.setUserVariables({snl:1, init:false})
}
The Re-creator of Old Games ;D
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post 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.
Paolo Bax
The SmartFoxServer Team
Bosskafett
Posts: 41
Joined: 24 Jan 2012, 00:04

Check out my code

Post 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)
}
}
if(_global.is_rocketsnail == 1){
mc.snail._visible = true;
smartfox.setUserVariables({snl:1, init:false})
}
The Re-creator of Old Games ;D
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post 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.
Paolo Bax
The SmartFoxServer Team
Bosskafett
Posts: 41
Joined: 24 Jan 2012, 00:04

thanks

Post by Bosskafett »

thanks for helping, I already figured this out. The variables now update properly.

Cheers Bax
if(_global.is_rocketsnail == 1){
mc.snail._visible = true;
smartfox.setUserVariables({snl:1, init:false})
}
The Re-creator of Old Games ;D
Post Reply