Way to inject text from server in chatbox?

Everything about the SmartFoxBits UI Components for SmartFoxServer 2X. Post your questions, suggestions and bug reports.

Moderators: Bax, Lapo

Way to inject text from server in chatbox?

Postby shaka » 08 Jul 2011, 01:52

Hi all,

I currently have a chatbox (named chatBox_mc). Is there any way I can use the server to display a message inside the chat box?

I tried messageQueue (chatBox_mc.messageQueue += "message" ) but I'm not sure how to do it correctly.

Thanks!
shaka
 
Posts: 45
Joined: 30 May 2011, 19:39

Postby Bax » 08 Jul 2011, 08:38

You could send a moderator message.
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
 
Posts: 3845
Joined: 29 Mar 2005, 09:50
Location: Italy

Postby shaka » 09 Jul 2011, 21:14

Hi bax, thanks for your help.

I looked into sending moderator message and found the following page:
http://docs2x.smartfoxserver.com/api-do ... quest.html

which does it for Actionscript. Looking back to my original post, I was pretty uninformative, so let me clarify!

In my game, at the end of each player's turn, the server does several actions which I'd like to have a text footprint (e.g. "Character A was moved to position X, Y!") displayed in the chatbox.

I'm looking at sendModeratorMessage (from here) but have a hard time finding an example of how to use it, as this is my first time programming something significant. Can anyone please give me something to work with?

Thanks again for your help!
shaka
 
Posts: 45
Joined: 30 May 2011, 19:39

Postby Bax » 10 Jul 2011, 12:25

What is not clear using the server-side sendModeratorMessage?
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
 
Posts: 3845
Joined: 29 Mar 2005, 09:50
Location: Italy

Postby shaka » 10 Jul 2011, 20:06

I don't know what library I have to import... I've tried
com.smartfoxserver.v2.api.SFSApi (and api.*), but in eclipse, the line: sendModeratorMessage(null, targetname + " takes" + damage + " damage", resObj, recipients);

"sendModeratorMessage" is underlined in red and says that it's not defined.
shaka
 
Posts: 45
Joined: 30 May 2011, 19:39

Postby Bax » 11 Jul 2011, 07:22

You must be doing something wrong. Please read again the documentation on Extensions development, and make sure you linked the proper libraries.
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
 
Posts: 3845
Joined: 29 Mar 2005, 09:50
Location: Italy

Postby shaka » 11 Jul 2011, 17:43

Bax, thanks for your help, but I'm still stumped.
I know I've correctly referenced sfs2x.jar and sfs2x-core.jar because I've been sending regular messages to my clients successfully, but my moderator messages still aren't working. :x Is there another library that I need to be referencing? (I can't find it.. :oops: )
shaka
 
Posts: 45
Joined: 30 May 2011, 19:39

Postby Bax » 12 Jul 2011, 08:53

Not sure what you are doing wrong. Inside the main extension code, or inside a request handler code, if I write:
Code: Select all
getApi().sendModeratorMessage(arg0, arg1, arg2, arg3)

everything is fine (if entering valid arguments of course).
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
 
Posts: 3845
Joined: 29 Mar 2005, 09:50
Location: Italy

Postby shaka » 12 Jul 2011, 17:46

Hi bax,

With your help, I've solved it! The big problem was i wasn't using getApi() in the beginning.

Thanks a lot for your help!

I actually have another question though: Is there a way to remove the white space between each moderator message? In the chatbox properties, I've set the Moderator message header text as "Game: ", but 2 lines of white space (<br>s?) keep appearing as such:


"

Game: Ranger moves to 4,4


Game: Ranger moves to 3,4

"

How can I remove these white spaces that appear before and after each moderator message?
shaka
 
Posts: 45
Joined: 30 May 2011, 19:39

Postby Bax » 13 Jul 2011, 08:08

I'm sorry but you can't (unless you purchased the Bits source code).
Those spaces have been added to highlight the admin/moderator message.
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
 
Posts: 3845
Joined: 29 Mar 2005, 09:50
Location: Italy

Postby shaka » 13 Jul 2011, 17:44

Alright, that's a pity. I've decided to just run with sendPublicMessage and force a user to say a message instead. Thanks for all your help, it saved me a lot of time!
shaka
 
Posts: 45
Joined: 30 May 2011, 19:39


Return to SmartFoxBits for SFS 2X

Who is online

Users browsing this forum: No registered users and 1 guest