Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Chat System (https://forums.graalonline.com/forums/showthread.php?t=134265114)

Gunderak 11-26-2011 09:12 AM

Chat System
 
This is just a really basic (bare bones) of a chat system.
I decided to post it here seeming as I have no use for it.
I originally scripted it just for fun.

PHP Code:

function onActionServerSide() {
  if (
params[0] == "add") {
    for (
temp.plallplayers) {
      
pl.triggerclient("weapon"this.name"add"player.nickparams[1]);
    }
  }
}
//#CLIENTSIDE
function onCreated() {
  new 
GuiWindowCtrl("Chat_Window") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "320,240";
    
canclose false;
    
canmaximize false;
    
canminimize false;
    
canmove false;
    
canresize false;
    
closequery false;
    
destroyonhide false;
    
text "Chat";
    
screenwidth width 2;
    
screenheight height 2;
    new 
GuiScrollCtrl("Chat_MultiLine_Scroll") {
      
profile GuiBlueScrollProfile;
      
height 221;
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
width 320;
      new 
GuiMLTextCtrl("Chat_MultiLine") {
        
profile GuiBlueMLTextProfile;
        
height 17;
        
horizsizing "width";
        
text "Welcome to the Chat system, Please be nice!";
        
width 295;
      }
    }
    new 
GuiTextEditCtrl("Chat_Bar") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 320;
      
220;
    }
  }
  
Chat_Window.destroy();
}

function 
Chat_Bar.onAction() {
  
triggerserver("weapon"this.name"add"Chat_Bar.text);
  
Chat_Bar.text "";
}

function 
onActionClientSide() {
  if (
params[0] == "add") {
    
Chat_MultiLine.addtext("<br>"@params[1]@": "@params[2], false);
    
Chat_MultiLine.scrolltobottom();
  }


Also if you have any suggestions to improve it feel free to let the idea's flow freely.

Crow 11-26-2011 12:51 PM

Don't send the player's nick with the trigger.

ffcmike 11-26-2011 01:15 PM

You might want to filter the chatbar aswell, or use a specific prefix (Classic just re-uses toall: ) as that would catch stuff like staff commands, sethead etc.

Gunderak 11-26-2011 01:16 PM

Changed and made the players nick send to all clients from serverside.

And what do you mean by a prefix?
The chat bar on this is solely for chatting and wasn't meant for staff commands or sethead.

ffcmike 11-26-2011 01:31 PM

Quote:

Originally Posted by Gunderak (Post 1675453)
Changed and made the players nick send to all clients from serverside.

And what do you mean by a prefix?
The chat bar on this is solely for chatting and wasn't meant for staff commands or sethead.

What I mean is that if you say "warpto levelname.nw" or "sethead head0.png" that will be caught by the chat system.

Gunderak 11-26-2011 01:55 PM

Ok, just a quick question.
Let's say for instance I want to do the warpto one.
I know how you would do it if there were only a level name.
You would use substrings, but how would you do it with three paramaters in the text?
Is there any way to get them by checking if there seperated by a space?

xAndrewx 11-26-2011 03:42 PM

temp.str = "warpto 30 30 level.nw";
temp.toks = temp.str.tokenize(" ");
echo(temp.toks[0]);

Gunderak 11-26-2011 04:17 PM

Thanks..

cbk1994 11-26-2011 04:29 PM

Quote:

Originally Posted by ffcmike (Post 1675452)
You might want to filter the chatbar aswell, or use a specific prefix (Classic just re-uses toall: ) as that would catch stuff like staff commands, sethead etc.

He's using Chat_Bar, a control he created. Not ChatBar, the actual chat bar.

ffcmike 11-26-2011 05:04 PM

Ah then I take that back, easy mistake to make with it being one character different.

Gunderak 11-26-2011 06:50 PM

1 Attachment(s)
You gotta watch out for them underscores!
They'l bite you in the arse when your not looking!


All times are GMT +2. The time now is 08:23 PM.

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