Hello,
is it possible to add a new User."Command"
i really need User.Age() , User.Sex(), etc
How easy is it to add this, i've looked in the advanced chat example, but cannot see where the User object is made, or how to edit it.
Many thanks.
User.getId() / user.getName() / Add a new one???
You can't add properties or methods to the User object.
But you can use the userVariables to add properties to each user. Check the "Avatar chat" tutorial in the online documentation.
But you can use the userVariables to add properties to each user. Check the "Avatar chat" tutorial in the online documentation.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Thanks for the reply bax,
I cannot seem to get the "getVariable" to work, I tried the following:
Then, in the onPublicMessage function, i want to access these varibles, from the "user" sending the message, not the "onUserVariablesUpdate" function. As once these varibles are set, they will not be updated again.
I tried the following:
All i get is undefined???
Please help.
working with smartfox so far is great, and the help on this forum is perfect!
I cannot seem to get the "getVariable" to work, I tried the following:
Code: Select all
smartfox.joinRoom(roomName)
smartfox.setUserVariables({age:"26",team:"16",init:true})
Then, in the onPublicMessage function, i want to access these varibles, from the "user" sending the message, not the "onUserVariablesUpdate" function. As once these varibles are set, they will not be updated again.
I tried the following:
Code: Select all
smartfox.onPublicMessage = function(msg:String, user:User)
{
chat_txt.htmlText += "<b>" + user.getName() + ": </b> " + user.getVariable('team') + msg
main_sb.setScrollPosition(chat_txt.maxscroll)
}
All i get is undefined???
Please help.
working with smartfox so far is great, and the help on this forum is perfect!
poppop wrote:I cannot seem to get the "getVariable" to work, I tried the following:Code: Select all
smartfox.joinRoom(roomName)
smartfox.setUserVariables({age:"26",team:"16",init:true})
This is wrong: you need to wait to be joined successfully into a room (so the onJoinRoom event) before setting the user variables.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Return to “SmartFoxServer 1.x Discussions and Help”
Who is online
Users browsing this forum: No registered users and 52 guests