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 05-03-2008, 11:09 PM
LalVlpShade LalVlpShade is offline
Muse
LalVlpShade's Avatar
Join Date: Jun 2007
Posts: 13
LalVlpShade is on a distinguished road
Send a message via AIM to LalVlpShade
Player chat problems (custom chat GUI)

I'm posting this for a friend, as he doesn't have any forum access, but really needs help with some scripting. Here's what he says:

On Valikorlia, I've written a custom chat GUI. It's based off of Inverness's staff console script, just in case anybody sees any similarities. The problem I'm having is that I cannot figure out how to make a player's chat text stay on for more than ~3 seconds.

It only stays for ~3 seconds because the player's chat is being set clientside. If I change it to being set serverside, it'll stay on longer. However, when it's set serverside, no clientside functions run by a player's chat (for instance, a staff function that sets your guild "/setguild GuildName" will only work if the player's chat is set on clientside) will work.

So, is it possible to send text to the serverside while still maintaining functionality as if it was set clientside, without rescripting all the commands to work on both? I've attached the code (forgive me if you don't like the style or if it's not super-efficient; I'm no ubercoder. If you see anything that you'd like to comment on, go ahead, but please remember the focus of this post ). Right now, a player's chat is set during ChatConsole_Chat.onAction().

PHP Code:
function sendtext(textspecialacct) {
  switch(
special) {
    case 
"pm":
      
with(findPlayer(acct))
        
clientfunction2(null,"sendtext"text);
    break;
    case 
"public":
      for(
temp.iplayers)
        
with(i)
          
clientfunction2(null"sendtext"text);
    break;
    case 
"announce":
      for(
temp.iallplayers)
        
with(i)
          
clientfunction2(null"sendtext"text);
    break;
  }
}
function 
onCreated() {
  
this.join("util_triggercontrol");
}
//#CLIENTSIDE
function onCreated() {
  
this.join("util_triggercontrol");
  
this.join("util_math");
  
this.version 1;
  
config();
  if(
client.chatconsoleversion != this.version)
    
client.chatconsoleversion this.version;
    
checkdefaults();
  
createcontrols();
  
ChatBar.destroy();
}
function 
onKeyPressed() {
  if(
params[0] == 9) {
    
this.trigger("ChatConsoleKey"null);
  }
}
function 
onChatConsoleKey() {
  if(
ChatConsole_Window.fading == true)
    return;
  if(
ChatConsole_Window.visible == false) {
    
ChatConsole_Window.fadein(0.25,1);
    
ChatConsole_Chat.makefirstresponder(true);
  } else {
    
ChatConsole_Window.fadeout(0.25,0);
  }
}
function 
createcontrols() {
  
with (new GuiWindowCtrl("ChatConsole_Window")) {
    
GUIContainer.addcontrol(this);
    
this.join("util_guifade");
    
this.useownprofile true;
    
this.profile.copyfrom(GuiBlueWindowProfile);
    
this.profile.transparency 0;
    
this.position client.chatconsoleposition;
    
this.extent client.chatconsoleextent;
    
this.minextent = {20080};
    
this.text "Valikorlia Chat Console";
    
this.canmove true;
    
this.canresize true;
    
this.canclose true;
    
this.canminimize true;
    
this.canmaximize true;
    
this.destroyonhide false;
    
this.tile true;
    
this.alpha 0;
    
this.visible false;

    new 
GuiScrollCtrl("ChatConsole_Scroll") {
      
this.useownprofile true;
      
this.profile.copyfrom(GuiBlueScrollProfile);
      
this.profile.bitmap "guiblue_scroll_noback.png";
      
this.profile.transparency 0;
      
this.profile.fillcolor = {0,0,0,192};
      
this.profile.border 3;
      
this.position = {624};
      
this.extent = {
        
client.chatconsoleextent[0]-12,
        
client.chatconsoleextent[1]-46
      
};
      
this.horizsizing "width";
      
this.vertsizing "height";
      
this.hscrollbar "alwaysOff";
      
this.vscrollbar "dynamic";

      new 
GuiMLTextCtrl("ChatConsole_Display") {
        
this.useownprofile true;
        
this.profile.copyfrom(GuiBlueMLTextProfile);
        
this.profile.fonttype client.chatconsolefont;
        
this.profile.fontcolor client.chatconsolefontcolor;
        
this.profile.fontsize client.chatconsolefontsize;
        
this.horizsizing "width";
        
this.position = {22};
        
this.wordwrap true;
        
this.extent = {
          
client.chatconsoleextent[0]-33,
          
client.chatconsoleextent[1]-58
        
};
        if (
text == "")
          
text thiso.welcometext;
      }
    }
    new 
GuiTextEditCtrl("ChatConsole_Chat") {
      
this.profile GuiBlueTextEditProfile;
      
this.horizsizing "width";
      
this.vertsizing "top";
      
this.position = {6client.chatconsoleextent[1] - 25};
      
this.extent = {client.chatconsoleextent[0]-1220};
      
this.historysize 100;
      
this.tabcomplete true;
    }
    
this.bringtofront();
    
thiso.catchevent("ChatConsole_Window""onResize""onChatConsoleResize");
    
thiso.catchevent("ChatConsole_Window""onMove""onChatConsoleMove");
  }
}
function 
onChatConsoleResize() {
  
client.chatconsoleextent = {ChatConsole_Window.width,ChatConsole_Window.height};
}
function 
onChatConsoleMove() {
  
client.chatconsoleposition = {ChatConsole_Window.x,ChatConsole_Window.y};
}
function 
ChatConsole_Chat.onAction(text) {
  
temp.text ChatConsole_Chat.text.substring(0,-1);
  
temp.textstarts text.tokenize();
  if(
text.starts("!"))
    
temp.text.substring(1).tokenize();
    
cmd(i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8],i[9]);
  if(
text == null)
    return;
  if(!
text.starts("warpto") && !text.starts("setnick") && text != null
  
&& !text.starts("!") && text != "unstickme" && !client.ooc)
    
player.chat text;
    
addtext(text);
  
ChatConsole_Chat.text "";
}
function 
sendtext(text) {
  
ChatConsole_Display.addtext("\n" text,1);
  
ChatConsole_Display.scrolltobottom();
}
function 
addtext(text) {
  
temp.nicktext 0;
  
temp.chattext text;
  
temp.total 0;
  
temp.stringtoarray(player.nick);
  if(
i.size() > 10temp.nicktext player.nick.substring(0,7) @ "...";
    else 
temp.nicktext player.nick;
  if(
player.guild == "RP Admin")
    
temp.total "<font color=orange>" player.nick ":" SPC chattext "</font>";
    else 
temp.total "<font color=limegreen>" nicktext ":</font>" SPC chattext;
  
serverfunction2(null,"sendtext",total,"public");
}
function 
cmd(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9) {
  switch(
p0) {
    case 
"help":
      
ChatConsole_Display.addtext(this.commandtext,1);
    break;
    case 
"clear":
      
ChatConsole_Display.text this.welcometext;
    break;
    case 
"pm":
      
player.chat "";
      
temp.sender "<font color=salmon>" player.account;
      
temp.to p1;
      
temp.text sender " [PM]: " p2 "</font>";
      
serverfunction2(null,"sendtext",text,"pm",to);
    break;
    case 
"announce":
      if(
clientr.staff != 1) return;
      else
        
temp.text "<font color=yellow>[ANNOUNCEMENT]: " p1 "</font>";
        
serverfunction2(null,"sendtext",text,"announce");
    break;    
    case 
"setfont":
      
client.chatconsolefont p1;
      
player.chat "/reconnect";
    break;
    case 
"setfontsize":
      
client.chatconsolefontsize p1;
      
player.chat "/reconnect";
    break;
  }
}
function 
checkdefaults() {
  if(!
client.chatconsolefillcolor)
    
client.chatconsolefillcolor this.defaultfillcolor;
  if(!
client.chatconsolefontcolor)
    
client.chatconsolefontcolor this.defaultfontcolor;
  if(!
client.chatconsoleposition)
    
client.chatconsoleposition this.defaultposition;
  if(!
client.chatconsoleextent)
    
client.chatconsoleextent this.defaultextent;
  if(!
client.chatconsolefont)
    
client.chatconsolefont this.defaultfont;
  if(!
client.chatconsolefontsize)
    
client.chatconsolefontsize this.defaultfontsize;
}
function 
config() {
  
this.defaultfillcolor = {000192};
  
this.defaultfontcolor = {192192192255};
  
this.defaultposition = {1639};
  
this.defaultextent = {397471};
  
this.defaultfont "Lucida Console";
  
this.defaultfontsize 11;
  
this.welcometext "<shadow:1:1><shadowcolor:000000>Welcome to the chat console<br>Type \"!help\" for a list of commands.";
  
this.commandtext "<shadow:1:1><shadowcolor:000000>";
  
this.commandtext @= "\n<font color=limegreen>COMMANDS:</font>";
  
this.commandtext @= "\n  <font color=limegreen>!help:</font> displays command information.";
  
this.commandtext @= "\n  <font color=limegreen>!clear:</font> clears the chat display.";
  
this.commandtext @= "\n  <font color=limegreen>!pm acct \"message\":</font> sends a PM to specified account.";
  if(
clientr.staff == 1)
    
this.commandtext @= "\n  <font color=limegreen>!announce \"message\":</font> sends an announcement to the entire server. (staff only)";
  
this.commandtext @= "\n<font color=limegreen>PREFERENCES:</font>";
  
this.commandtext @= "\nBelow commands will automatically reconnect you.";
  
this.commandtext @= "\n  <font color=limegreen>!setfont:</font> sets a custom font.";
  
this.commandtext @= "\n  <font color=limegreen>!setfontsize:</font> sets a custom font size.";

Reply With Quote
  #2  
Old 05-03-2008, 11:14 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
See this thread: http://forums.graalonline.com/forums...ad.php?t=75087

The only solution was to make a custom chat display.
__________________
Reply With Quote
  #3  
Old 05-03-2008, 11:21 PM
LalVlpShade LalVlpShade is offline
Muse
LalVlpShade's Avatar
Join Date: Jun 2007
Posts: 13
LalVlpShade is on a distinguished road
Send a message via AIM to LalVlpShade
He was hoping to avoid using a timeout, but if that's the only way. Bleh.

Is there a reason why Stefan only has player.chat show for 3 seconds on clientside?
Reply With Quote
  #4  
Old 05-03-2008, 11:47 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 LalVlpShade View Post
He was hoping to avoid using a timeout, but if that's the only way. Bleh.

Is there a reason why Stefan only has player.chat show for 3 seconds on clientside?
I think I heard so it isn't abused ... you'd have to ask him.
__________________
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 08:58 PM.


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