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 08-04-2011, 09:05 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
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

Here Is A Screenshot.

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();

__________________

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; 08-04-2011 at 10:09 AM..
Reply With Quote
  #2  
Old 08-04-2011, 09:11 AM
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 cbk1994 View Post
The biggest problem with your script is that it's not formatted consistently.
..
__________________
Reply With Quote
  #3  
Old 08-04-2011, 09:22 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
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.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #4  
Old 08-04-2011, 11:34 AM
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
Quote:
Originally Posted by Gunderak View Post
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.
Reply With Quote
  #5  
Old 08-04-2011, 09:26 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Iv updated the script to be serverside.
i hope it now displays the chat properly.
__________________

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; 08-04-2011 at 10:11 AM..
Reply With Quote
  #6  
Old 08-04-2011, 10:14 AM
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
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.
Reply With Quote
  #7  
Old 08-04-2011, 01:33 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 Mark Sir Link View Post
I'm not sure if player.isadmin returns correctly on the clientside
For the record, it doesn't.
__________________
Reply With Quote
  #8  
Old 08-04-2011, 11:09 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
The chat is only displaying clientside.. aka only showing what yourself chats and no one elses X_X
__________________

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 08-04-2011, 12:12 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
Quote:
Originally Posted by Gunderak View Post
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
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 09:44 AM.


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