Advanced Buddylist/ buddylist 2.0

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

Moderators: Lapo, Bax

User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Advanced Buddylist/ buddylist 2.0

Postby rjgtav » 18 Sep 2009, 15:20

Hi there. I liked the buddylist 2.0 and i putted it in my game. The problem is that when i send the buddy request, on the server debug appears that it sent the request but on the other client, the function onBuddyPermissionRequest doesn't fire. could you help me? ty.

Version: Smartfoxserver Pro 1.6.6

As: 2.0

debug:

Code: Select all

2009/09/18 16:04:26.988 - [ INFO ] [id: 11] (SystemHandler.askAddBuddyPermission): Asking buddy permission. Sender: Rjgtav, Target:it.gotoandplay.smartfoxserver.data.User@cec888


script:

Code: Select all

function addBuddy()
{
   var item:Object = _root.userList_lb.getSelectedItem()
   
   if (item != undefined)
   {
      smartfox.addBuddy(item.label)
      trace(item.label)
   }
}

smartfox.onBuddyPermissionRequest = function(sender:String, message:String):Void
{
   trace("buddy permission")
   _root.openwindow(_root.buddypermission)
   _root.buddypermission.txt = sender+" is asking you if you want to be his/her friend. Do you want to be his/her friend?"
}


Pls help me. ty.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 19 Sep 2009, 12:54

Are you sure the BuddyList settings are properly set?
You need this:

Code: Select all

<mutualAddBuddy>true</mutualAddBuddy>
<mutualRemoveBuddy>true</mutualRemoveBuddy>

in your buddy list config to make it work correctly.
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 20 Sep 2009, 13:51

Hi there. Here is my server config:

Code: Select all

<BuddyList active="true">
            <size>200</size>
            <maxBuddyVariables>10</maxBuddyVariables>
            <mode>advanced</mode>
            
            <!-- Apply only for advanced mode -->
            <offLineBuddyVariables>true</offLineBuddyVariables>
            <permissionTimeOut>10</permissionTimeOut>
            <mutualAddBuddy>true</mutualAddBuddy>
            <mutualRemoveBuddy>true</mutualRemoveBuddy>
</BuddyList>
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 21 Sep 2009, 07:55

Everything seems correct.
I would suggest that you take a look at our Actionscript 2 version of the Advanced Buddy List example and compare your code with it.

The example is located in Examples/24_pro_buddyList2/
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 21 Sep 2009, 14:06

Hi there. I have used the script from your example, but i've changed some things because you use smartfoxbits events and i use smartfoxserver's.
Here are your scripts and mine:

Your scipt:

Code: Select all

sfs.onBuddyPermissionRequest = onBuddyPermissionRequest
...
function onBuddyPermissionRequest(sender:String, message:String):Void
{
   mc_alert.lb_name.text = sender
   mc_alert._visible = true
}


My:

Code: Select all

smartfox.onBuddyPermissionRequest = function(sender:String, message:String)
{
   trace("buddy permission")
   _root.openwindow(_root.buddypermission)
   _root.buddypermission.txt = sender+" is asking you if you want to be his/her friend. Do you want to be his/her friend?"
}


Your:

Code: Select all

function bt_addBuddy_click():Void
{
   if ( tf_buddyName.text != "" )
   {
      sfs.addBuddy( tf_buddyName.text )
      tf_buddyName.text = ""
   }
}


My:

Code: Select all

function addBuddy(buddyname)
{
   
   if (buddyname != _global.myName)
   {
      if(buddyname != ""){
      smartfox.addBuddy(buddyname)
      _root.addbuddyname = "";
      }else{
            _root.mainchat.parseText("[System] Please insert the player's name.")
            _root.privchat.parseText("[System] Please insert the player's name.")
      }
   }else{
      _root.mainchat.parseText("[System] Please insert the player's name, not your name.")
            _root.privchat.parseText("[System] Please insert the player's name, not your name.")
   }
}


The problem is that the client sends the request, but the other client doesn't recieve it. Please help me. Thank you.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 22 Sep 2009, 18:40

Do i need this line that is in your examples script?

Code: Select all

import it.gotoandplay.smartfoxbits.events.*


*EDIT*

I've already read the docs lots of times and i still don't understand why the onBuddyPermissionRequest function doesn't fire.

*EDIT 2*

I don't know if this is normal, but i openned the advancedBudyList fla and tested it, but the flash gave errors on buddy's properties saying that there is no method/property with that name. Maybe this has something to do with my bugs but in my game, the flash doesn't give any error.

This is the output:

Code: Select all

There is no property with the name 'onBuddyPermissionRequest'.
There is no property with the name 'sendBuddyPermissionResponse'.
There is no property with the name 'getBuddyByName'.
There is no property with the name 'setBuddyBlockStatus'.
There is no property with the name 'getBuddyById'.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 23 Sep 2009, 13:28

Does our example work for you?
As regards SmartFoxBits, they don't get in the way with the buddy list, so the buddy list related code is not affected.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 23 Sep 2009, 14:20

Code: Select all

 There is no property with the name 'onBuddyPermissionRequest'.
There is no property with the name 'sendBuddyPermissionResponse'.
There is no property with the name 'getBuddyByName'.
There is no property with the name 'setBuddyBlockStatus'.
There is no property with the name 'getBuddyById'.


None of them are properties, they are methods.
What are you doing?
Maybe you have conflicting API versions? Trace the current API version by calling the getVersion() method on the SmartFoxClient instance.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 23 Sep 2009, 18:13

Hi there. Please sorry for my mistake. I don't understand how, but your example (that worked on the past) started using API 1.4.4 (i think that was that version) but i've already solved the problem by putting the it folder in the same folder as the example. Now it's using API 1.5.8. Ty for the help. Now i only need to solve the problem with my game.

*EDIT*

I believe that it was a miracle. Now the game already fires the function when receives the addbuddy request. Is there a way to send to the sender a message saying if the target player have accepted or not the buddy request?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 28 Sep 2009, 15:29

Lapo, could you please help me with my last question? Any help would be appreciated.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 29 Sep 2009, 06:41

No, but you can create a custom message if you wish, in your extension code.
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 63 guests