Graal Forums

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

Gunderak 08-04-2011 09:05 AM

Customized Chat Script
 
Basically it will disable the default chat above the players head, and instead it will be placed in a box :)
if the player has clientr.isStaff added their name will be red.
thanks to mark sir link and cbk1994 for their help with this.
feel free to use it on your server if you want to,
but please do not claim it as your own :D

Here Is A Screenshot.
http://i56.tinypic.com/t8ojs4.png
PHP Code:

function onActionServerSide(){
if ( 
params[0] == "AddMessage" ) {
triggerclient("weapon"this.name"AddMessage2");
}
}
//#CLIENTSIDE
function onCreated() {
ChatBar.width 600;
ChatBar.alpha 0.7;
ChatBar.profile GuiBlueTextEditProfile;
ChatBar.height 25;
ChatBar.810;
ChatBar.0;
    new 
GuiScrollCtrl("Chat_Text_Scroll") {
      
profile GuiBlueScrollProfile;
      
height 100;
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
width 600;
      
0;
      
708;

      new 
GuiMLTextCtrl("Chat_Text") {
        
profile GuiBlueMLTextProfile;
        
height 68;
        
horizsizing "width";
        
text "Welcome To "@servername@" "@player.nick@"."@"<br>"@"You Can Write /help For Help At Any Time!";
        
width 575;
      }
    }
  }
function 
onPlayerchats(){
if(
player.chat == "/help"){
Chat_Text.addtext("<br>"@"<font color=black>"@"If You Get Stuck Anywhere Write ''Unstuck Me''"@"<br>"@"To See The Server News Write /news"@"<font color=white>"false);
return;
}
triggerserver("weapon"this.name"AddMessage");
}
function 
onActionClientSide(){
  if ( 
params[0] == "AddMessage2" ) {
}
if(
player.chat.starts("/")){
return;
}
if(
player.chat.starts("warpto")){
return;
}
if(
player.chat.starts("update")){
return;
}
if(
player.chat.starts("unstuck")){
return;
}
if(
player.chat.starts("set")){
return;
}
if(
clientr.isStaff){
Chat_Text.addtext("<br>"@"<font color = red>"@player.nick@": "@"<font color=white>"@player.chatfalse);
Chat_Text.scrolltobottom();
return;
}
   
Chat_Text.addtext("<br>"@player.nick@": "@player.chatfalse);  
   
Chat_Text.scrolltobottom();



cbk1994 08-04-2011 09:11 AM

Quote:

Originally Posted by cbk1994 (Post 1661203)
The biggest problem with your script is that it's not formatted consistently.

..

Gunderak 08-04-2011 09:22 AM

Do you care to explain further please?
what can you see wrong with it atm :3?
thanks btw.
its only by people telling me that il be able to fix.

Gunderak 08-04-2011 09:26 AM

Iv updated the script to be serverside.
i hope it now displays the chat properly.

Mark Sir Link 08-04-2011 10:14 AM

go back to the thread I posted in and look at how onPlayerChats an onRemotePlayerChats are used. Chat is already available on the clientside so there is no point in sending and receiving that data once again.

I'm not sure if player.isadmin returns correctly on the clientside, but isadminguild(player.guild) should work fine, and that is probably preferable.

Gunderak 08-04-2011 11:09 AM

The chat is only displaying clientside.. aka only showing what yourself chats and no one elses X_X

Crow 08-04-2011 11:34 AM

Quote:

Originally Posted by Gunderak (Post 1661648)
Do you care to explain further please?

It's ugly/unreadable. Make sure your scripts look like this or similar so they are easily readable by yourself later and by other coders:
PHP Code:

function onActionServerSide() {
  if (
params[0] == "AddMessage") {
    
triggerclient("weapon"this.name"AddMessage2");
  }
}

//#CLIENTSIDE
function onCreated() {
  
ChatBar.width 600;
  
ChatBar.alpha 0.7;
  
ChatBar.profile GuiBlueTextEditProfile;
  
ChatBar.height 25;
  
ChatBar.810;
  
ChatBar.0;
  new 
GuiScrollCtrl("Chat_Text_Scroll") {
    
profile GuiBlueScrollProfile;
    
height 100;
    
hscrollbar "dynamic";
    
vscrollbar "dynamic";
    
width 600;
    
0;
    
708;
    new 
GuiMLTextCtrl("Chat_Text") {
      
profile GuiBlueMLTextProfile;
      
height 68;
      
horizsizing "width";
      
text "Welcome To "@servername@" "@player.nick@"."@"<br>"@"You Can Write /help For Help At Any Time!";
      
width 575;
    }
  }
}

function 
onPlayerchats() {
  if (
player.chat == "/help") {
    
Chat_Text.addtext("<br>"@"<font color=black>"@"If You Get Stuck Anywhere Write ''Unstuck Me''"@"<br>"@"To See The Server News Write /news"@"<font color=white>"false);
    return;
  }
  
triggerserver("weapon"this.name"AddMessage");
}

function 
onActionClientSide() {
  if (
params[0] == "AddMessage2") {}
  if (
player.chat.starts("/")) {
    return;
  }
  if (
player.chat.starts("warpto")) {
    return;
  }
  if (
player.chat.starts("update")) {
    return;
  }
  if (
player.chat.starts("unstuck")) {
    return;
  }
  if (
player.chat.starts("set")) {
    return;
  }
  if (
clientr.isStaff) {
    
Chat_Text.addtext("<br>"@"<font color = red>"@player.nick@": "@"<font color=white>"@player.chatfalse);
    
Chat_Text.scrolltobottom();
    return;
  }
  
Chat_Text.addtext("<br>"@player.nick@": "@player.chatfalse);
  
Chat_Text.scrolltobottom();


That's not ideal, but better than yours.

Mark Sir Link 08-04-2011 12:12 PM

Quote:

Originally Posted by Gunderak (Post 1661661)
The chat is only displaying clientside.. aka only showing what yourself chats and no one elses X_X

because you're not using onRemotePlayerChats or triggering clients properly. For your triggerclient to work, you'd have to cycle through allplayers on the serverside and send them each a triggerclient individually. However, this is pointless and wasting resources since the chat is already available on the clientside by virtue of you being able to read it.

Also, the way you are checking for staff would not work at all, it will display red names for any player who logs in and is staff (regardless of who is chatting), and any normal player would see staff chat without red names.

Go back to the other thread and look at the example I posted and follow it a bit more carefully, and modify the addChat function to suit your specific needs

cbk1994 08-04-2011 01:33 PM

Quote:

Originally Posted by Mark Sir Link (Post 1661658)
I'm not sure if player.isadmin returns correctly on the clientside

For the record, it doesn't.


All times are GMT +2. The time now is 05:00 AM.

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