I am constructing a chat room system to get comfortable with using triggerserver and triggerclient. I am having some issues however. The chat won't appear on other players screens! I think the message is actually being sent to the serverside then back to the clientside because of a 0.5 second delay for the message to appear, but the other players in the chat room aren't actually receiving any messages. Here is the code.
PHP Code:
function onActionServerSide() {
if (params[0] == "sendtext") {
triggerclient("weapon", this.name, "gettext", params[1]);
}
}
//#CLIENTSIDE
function onCreated() {
new GuiWindowCtrl("Msg_Window1") {
profile = GuiBlueWindowProfile;
clientrelative = true;
clientextent = "320,240";
canmaximize = false;
canmove = true;
canresize = false;
closequery = false;
destroyonhide = true;
text = "Staff Chat Channel";
x = 517;
y = 203;
new GuiScrollCtrl("Msg_Chatbox_Scroll") {
profile = GuiBlueScrollProfile;
height = 215;
hscrollbar = "dynamic";
vscrollbar = "dynamic";
width = 316;
x = 2;
y = 2;
new GuiMLTextCtrl("Msg_Chatbox") {
profile = GuiBlueMLTextProfile;
height = 17;
horizsizing = "width";
text = "<b><font color = white>System</b>: Input /clear to clear the message box.";
width = 312;
}
}
new GuiTextEditCtrl("Msg_ChatBar") {
profile = GuiBlueTextEditProfile;
height = 20;
width = 316;
x = 2;
y = 219;
}
}
}
function Msg_ChatBar.onAction() {
temp.msg = "";
if (Msg_ChatBar.text == "/clear") {
Msg_Chatbox.text = "Cleared!";
} else {
if (Msg_ChatBar.text != NULL) {
temp.msg = Msg_ChatBar.text;
triggerserver("weapon", this.name, "sendtext", temp.msg);
Msg_ChatBar.text = "";
}
}
if (temp.msg.starts("/font ")) {
say2("Works");
}
}
function onActionClientSide() {
if (params[0] == "gettext") {
if (clientr.isStaff) {
Msg_Chatbox.addtext("<br><b><font color = yellow>" @ player.nick @ "</b>: " @ params[1], false);
Msg_ChatBox.scrolltobottom();
} else {
Msg_Chatbox.addtext("<br><b><font color = cyan>" @ player.nick @ "</b>: " @ params[1], false);
Msg_ChatBox.scrolltobottom();
}
}
}
Thanks for any help I receive.