need help

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

User avatar
zachofthegolden1
Posts: 89
Joined: 05 Sep 2011, 19:31

need help

Postby zachofthegolden1 » 05 Sep 2011, 19:40

Hello, i'm new here, i recently got smartfox server pro, ive setup my game :D
but i need a little help with some features i wanted to add

i wanted to add some badges whitch i have

Image


but threes this 1 badge i want only moderators to have so if there a mod that badge will show for them

Image

so like this badge will show for everyone but only moderators will have it on their name tag, so far ive got the badge to show for everyone and everyone hat
-ZG1
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 05 Sep 2011, 19:50

Hi. Welcome to the Forums!

Well, in the User object there is a method called isModerator(). This method returns a boolean which is true when an User is a moderator or false when isn't.

So, in the onUserEnterRoom() event, you can simply check if the user is or not a moderator and show or hide the badges.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
User avatar
zachofthegolden1
Posts: 89
Joined: 05 Sep 2011, 19:31

Postby zachofthegolden1 » 05 Sep 2011, 19:59

thank you for the quick reply, im still kinda lost on it, ive checked the join room there isn't a boolen flag but it says false
-ZG1
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 05 Sep 2011, 20:48

Hi. For checking if the current client is a moderator, you need to use the amIModerator property of the SmartFoxClient class.

For checking if other user is a Moderator, you can do it on the onUserEnterRoom event, and use the User.isModerator() method.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
User avatar
zachofthegolden1
Posts: 89
Joined: 05 Sep 2011, 19:31

Postby zachofthegolden1 » 05 Sep 2011, 20:54

is there a example code i could use? because ive set the moderators bade to modbadge everytime i enter it in and hide from other users my avatar wont show O.O

Code: Select all

//----------------------------------------------------------
// Handles a new user entering the room
//----------------------------------------------------------
smartfox.onUserEnterRoom = function(fromRoom, user)
{
   var userId:Number   = user.getId()
   var userName:String   = user.getName() User.isModerator()
   
   
   // Add user to the userList listbox
   userList_lb.addItem(userName, userId)
   
   // Sort names
   userList_lb.sortItemsBy("label", "ASC")
   
   updateRoomStatus(fromRoom)
   
   // Show the user avatar
   var mc:MovieClip = avatarMC.attachMovie("avatar", "avatar_" + userId, userId)

   mc._x          = user.variables["px"]
   mc._y          = user.variables["py"]
   mc.name.text    = userName

   mc.disc.gotoAndStop(user.variables["col"])
}
[/code]
-ZG1
User avatar
zachofthegolden1
Posts: 89
Joined: 05 Sep 2011, 19:31

Postby zachofthegolden1 » 10 Sep 2011, 11:50

its not working :( is there a exampe file or something im really lost
-ZG1
Aiidenb
Posts: 263
Joined: 16 Aug 2010, 22:08
Location: England
Contact:

Postby Aiidenb » 10 Sep 2011, 12:09

zachofthegolden1 wrote:its not working :( is there a exampe file or something im really lost


You can user some userVars for the badges.

You could use something like this..
http://sfs-tutorials.blogspot.com/2010/ ... orial.html
Quackbay - The online virtual world for kids!
User avatar
zachofthegolden1
Posts: 89
Joined: 05 Sep 2011, 19:31

Postby zachofthegolden1 » 10 Sep 2011, 13:17

i love the site and ive tried the boolns for the if mderator show badge, right now i set the badge to hidden so its there but no one can see it, also i tried the veribals it works if i have a button but then everyone else is able to click it
-ZG1
Aiidenb
Posts: 263
Joined: 16 Aug 2010, 22:08
Location: England
Contact:

Postby Aiidenb » 10 Sep 2011, 13:46

zachofthegolden1 wrote:i love the site and ive tried the boolns for the if mderator show badge, right now i set the badge to hidden so its there but no one can see it, also i tried the veribals it works if i have a button but then everyone else is able to click it

Try something like;

Code: Select all

if(_global.myName = "YOUR NAME"){
_root.BUTTONNAME._visible = true;
}
Quackbay - The online virtual world for kids!
User avatar
zachofthegolden1
Posts: 89
Joined: 05 Sep 2011, 19:31

Postby zachofthegolden1 » 10 Sep 2011, 13:53

Aiidenb wrote:
zachofthegolden1 wrote:i love the site and ive tried the boolns for the if mderator show badge, right now i set the badge to hidden so its there but no one can see it, also i tried the veribals it works if i have a button but then everyone else is able to click it

Try something like;

Code: Select all

if(_global.myName = "YOUR NAME"){
_root.BUTTONNAME._visible = true;
}


i tried that everytime i logged in without a name the nae was test so whatever user name i set for it to show for everyone who logs in without entering a name so instead of guest_5 its the username test
-ZG1
Aiidenb
Posts: 263
Joined: 16 Aug 2010, 22:08
Location: England
Contact:

Postby Aiidenb » 10 Sep 2011, 17:50

What about;

Code: Select all

if (_global.myName == "YOUR NAME") {
   _root.BUTTONNAME._visible = true;
} else {
   if (_global.myName != "YOUR NAME") {
      _root.BUTTONNAME._visible = false;
   }
}

Quackbay - The online virtual world for kids!
User avatar
zachofthegolden1
Posts: 89
Joined: 05 Sep 2011, 19:31

Postby zachofthegolden1 » 11 Sep 2011, 15:29

ok i found a way around this but not thw way i have hoped, basically i make the game with al the eatures then publish then i make another button and oublish under a new name then for me i go to the one with button and normal players go to the app without button when i click it shows a avatar with the hair i like and the mod badge. also the game yoville have made it when ever someones mod level goes higher then 1 they get a mod badge on their name tag
-ZG1
User avatar
zachofthegolden1
Posts: 89
Joined: 05 Sep 2011, 19:31

Postby zachofthegolden1 » 13 Sep 2011, 17:47

rjgtav wrote:Hi. Welcome to the Forums!

Well, in the User object there is a method called isModerator(). This method returns a boolean which is true when an User is a moderator or false when isn't.

So, in the onUserEnterRoom() event, you can simply check if the user is or not a moderator and show or hide the badges.


ive done some testing i understand now is there a certain tag i should use? like it says trace "I am a moderator in this zone" what if i chagged it to this.modBadge._visable.true
-ZG1
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 13 Sep 2011, 19:00

What do you mean by a tag? you simply use those methods and they return either true or false, it is as simple as that.

They return true when you or the user is a moderator and false when you aren't. simple
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
User avatar
zachofthegolden1
Posts: 89
Joined: 05 Sep 2011, 19:31

Postby zachofthegolden1 » 13 Sep 2011, 20:24

ok it worked to identify ive placd a mod badge with the instance modBadge so ill try to figre a way to hide it
-ZG1

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 45 guests