HandleChatMessage question

suspectDevice12suspectDevice12

很久以前 | 帖子#1
I am working on a game where I want to send private messages through the chat system. I am experimenting with overloading the HandleChatMessage() method, however I can not figure out how to display the text message to only 1 user. Any ideas?

Cyclone103Cyclone103

很久以前 | 帖子#2
For the user who typed the message,
Player.send("chathandled", msg)

To send it to a user who is not the one who typed it, have some code take the second string in the array and place it into the variable "usertosend"

So if the command is /message Cyclone103 Hi! How are you? it will parse Cyclone103 as usertosend. Concatenate everything past the second part into a single string, msg.

Use this code on the serverside:

Broadcast("messagerecieved", usertosend, msg)

Have the clientside code check if the current user has the username stored in usertosend, if they don't, it should not do anything to the message and it should not parse it.

If they do, use the addChildToChat method and add the text.

If you want a complete code for this, PM me, as I have worked it out.

suspectDevice12suspectDevice12

很久以前 | 帖子#3
Thank you much for the help! I was hoping there was some kind of flag I could use. But I got it working your way.

My new Question is what did you do for NonobaAPI.AddChildToChat(s:Sprite)?

I passed it a sprite with a TextField for a child, and it looks ugly. Did you find an easy way to make the text look and feel like what nonoba is using?

Cyclone103Cyclone103

很久以前 | 帖子#4
No problem!

They actually provide a great example in the documentation for adding text to the chatbox, here, and the example works great. You can format the text, and change its color and background with the normal attributes of the field.

suspectDevice12suspectDevice12

很久以前 | 帖子#5
Perfect, that was the last piece of the puzzle. Not sure how I missed it when I was looking through the documentation.

thanks again

Cyclone103Cyclone103

很久以前 | 帖子#6
You're welcome!

回复主题

现在就注册以回复主题

5dyouxi

5dyouxi.com是一个独立的游戏网站,在这里你将可以免费玩到各种好玩的单人和多人游戏。

开发者工具

如果你是一位flash游戏开发者,我们有一些非常强大的工具来帮助你开发更加优秀的游戏。

经典游戏

为什么不试试我们这里的一些最为优秀的在线flash游戏呢?这可是完全免费的!

Copyright ©2007-2012 5dyouxi™ - All rights reserved.31.2001ms on SERVER34096
注册 或者