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(text, special, acct) {
switch(special) {
case "pm":
with(findPlayer(acct))
clientfunction2(null,"sendtext", text);
break;
case "public":
for(temp.i: players)
with(i)
clientfunction2(null, "sendtext", text);
break;
case "announce":
for(temp.i: allplayers)
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 = {200, 80};
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 = {6, 24};
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 = {2, 2};
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 = {6, client.chatconsoleextent[1] - 25};
this.extent = {client.chatconsoleextent[0]-12, 20};
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.i = 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.i = stringtoarray(player.nick);
if(i.size() > 10) temp.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 = {0, 0, 0, 192};
this.defaultfontcolor = {192, 192, 192, 255};
this.defaultposition = {16, 39};
this.defaultextent = {397, 471};
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.";
}