Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-04-2011, 08:27 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Chat room issue

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";
    
517;
    
203;

    new 
GuiScrollCtrl("Msg_Chatbox_Scroll") {
      
profile GuiBlueScrollProfile;
      
height 215;
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
width 316;
      
2;
      
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;
      
2;
      
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.
__________________
Reply With Quote
  #2  
Old 09-04-2011, 08:57 PM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
You are only sending the message to the player that triggered the server. To trigger all players in the chatroom, loop through them, and trigger them like so:
playerobj.triggerclient(stuff);
Reply With Quote
  #3  
Old 09-04-2011, 09:06 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
So would I have to do...
PHP Code:
function onActionServerSide() { 
  if (
params[0] == "sendtext") { 
    
playerobj.triggerclient("weapon"this.name"gettext"params[1]); 
  } 

__________________
Reply With Quote
  #4  
Old 09-04-2011, 09:09 PM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
Something like this:
PHP Code:
function onActionServerSide() { 
  if (
params[0] == "sendtext")
    for (
temp.plplayersinthechatroom
      
pl.triggerclient("weapon"this.name"gettext"params[1]); 

Reply With Quote
  #5  
Old 09-04-2011, 09:09 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
This is how:

PHP Code:
// other code
for (temp.plallplayers) {
  if (
temp.pl.level != NULL) {
    
temp.pl.triggerclient(this.name"gettext"params[1]);
  }
}
// other code 
If players can be in different chat rooms then you can use:

if (temp.pl.clientr.chatroom == clientr.chatroom)

Instead of sending it to everyone.
__________________
Quote:
Reply With Quote
  #6  
Old 09-05-2011, 12:11 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Now, whenever you receive a new message, the scroll bar scrolls all the way to the right of the multi line box. Is there any way to disable the horizontal scroll bar?
I can't post the code because my browser gives a security risk error when I post it, so here is the Graal paste bin link.
Code
__________________
Reply With Quote
  #7  
Old 09-05-2011, 12:53 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
hscrollbar = "alwaysOn", "alwaysOff", "dynamic"
Reply With Quote
  #8  
Old 09-05-2011, 01:00 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by Mark Sir Link View Post
hscrollbar = "alwaysOn", "alwaysOff", "dynamic"
<3 Thank you!
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:37 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.