Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-26-2011, 09:12 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
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.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion

Last edited by Gunderak; 11-26-2011 at 01:16 PM..
Reply With Quote
  #2  
Old 11-26-2011, 12:51 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Don't send the player's nick with the trigger.
Reply With Quote
  #3  
Old 11-26-2011, 01:15 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
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.
Reply With Quote
  #4  
Old 11-26-2011, 01:16 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
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.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #5  
Old 11-26-2011, 01:31 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Gunderak View Post
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.
Reply With Quote
  #6  
Old 11-26-2011, 01:55 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
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?
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #7  
Old 11-26-2011, 03:42 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
temp.str = "warpto 30 30 level.nw";
temp.toks = temp.str.tokenize(" ");
echo(temp.toks[0]);
__________________
Reply With Quote
  #8  
Old 11-26-2011, 04:17 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Thanks..
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #9  
Old 11-26-2011, 04:29 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by ffcmike View Post
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.
__________________
Reply With Quote
  #10  
Old 11-26-2011, 05:04 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Ah then I take that back, easy mistake to make with it being one character different.
Reply With Quote
  #11  
Old 11-26-2011, 06:50 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
You gotta watch out for them underscores!
They'l bite you in the arse when your not looking!
Attached Thumbnails
Click image for larger version

Name:	hehehe.png
Views:	159
Size:	22.3 KB
ID:	54028  
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
Reply


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 07:01 AM.


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