PDA

View Full Version : GlobalMsg - Client for Global Messaging System


Rapidwolve
02-02-2007, 04:54 AM
Client Messaging System
Version: 0.6.3b
for Global Message/Event System (by Ziro and Joey)
by rapidwolve
/*
Febuary 1st, 2007
by Rapidwolve
Version: 0.6.3b
For EventsBot => v4.10

Included:
+>> Basic Functions
+>> Options

Next Release:
+>> No need for quotes
+>> Serverlists for PM function
+>> No Quotes
+>> Working Options
+>> PM Function

Help:
+>> To answer trivia questions say /trivia #
+>> To clear console text say /clear
+>> Use quotes (e.g "Testing Script")

*/

//#CLIENTSIDE
function onCreated() {
requesttext("clientrc", 1);
}

function onKeyPressed(code, key) {
if (key == "c") {
openWin();
}
}

public function openWin() {

new GuiWindowCtrl("GlobalMsg_Console-MainWin") {
profile = "GuiBlueWindowProfile";
visible = true;
extent = {550, 380};
canClose = canMaximize = canResize = false;

thiso.buttons = {
"PM",
"Options",
"Close"};
thiso.buttonspos = {406, 453, 500};

for (i = 0; i < thiso.buttons.size(); i++) {
new GuiButtonCtrl("GlobalMsg_Button_" @ thiso.buttons[i]) {
profile = "GuiBlueButtonProfile";
text = thiso.buttons[i];
x = thiso.buttonspos[i][0];
y = 353;
extent = {45, 21};
thiso.catchevent(name, "onAction", "onClicked");
}
}

new GuiScrollCtrl("GlobalMsg_Console-Scroll1") {
hScrollBar = "alwaysOff";
vScrollBar = "dynamic";
position = {6, 22};
profile = "GuiBlueScrollProfile";
extent = {400, 330};


new GuiMLTextCtrl("GlobalMsg_Console-Text") {
position = {2, 0};
profile = "GuiBlueMLTextProfile";
extent = {330, 10};
if (text == null)
text = "Scripted by RW*";
}
}

new GuiScrollCtrl("GlobalMsg_Console-Scroll2") {
hscrollbar = "alwaysOff";
vscrollbar = "dynamic";
profile = "GuiBlueScrollProfile";
position = {406, 22};
extent = {137, 330};

}

new GuiTextEditCtrl("GlobalMsg_Console-TextEdit1") {
profile = "GuiBlueTextEditProfile";
position = {6, 352};
extent = {400, 22};
thiso.catchevent(name, "onAction", "sendMsg");
historySize = 100;
}
}
}


function sendMsg(textedit, message) {
tok = message.tokenize();
textedit.text = "";
if (tok[0].starts("/trivia")) {
sendtorc("/npctrivia" SPC tok[1]);
}
if (tok[0] == "/clear") {
("GlobalMsg_Console-Text").text = "Scripted by RW*";
}
if (!tok[0].starts("/")) {
sendtorc("/npcglobalmsg" SPC message);
player.chat = message;
}
}

function onRCChat(message) {
temp.starts = {
"[ Trivia Bot ]",
"Global Message sent successfully by",
"Global Message from",
};
if (message.starts(temp.starts[0]) || message.starts(temp.starts[1]) || message.starts(temp.starts[2])) {

normalcolor = "limegreen";
tcolon = message.pos(":");
nmessage = "<font color="@[email protected]"><b>";
nmessage @= message.substring(0, tcolon + 1) @ "</font></b>" @ message.substring(tcolon + 1, -1);
("GlobalMsg_Console-Text").addText("\n" @ nmessage, true);
("GlobalMsg_Console-Text").scrolltobottom();
}
}


function onClicked(btn) {
temp.btn = btn.substring(17);

if (temp.btn == "Close") {
onCloseAll();
}

if (temp.btn == "Options") {
openOptionsWin();
}

if (temp.btn == "PM") {
openPMWin();
}
}

function onCloseAll() {
("GlobalMsg_OptionsWin").destroy();
("GlobalMsg_Console-MainWin").destroy();
}

function onClose(win) {
win.parent.destroy();
}

function SaveandClose(win) {
temp.option.privatemessaging = ("Option_privatemessaging").checked;
temp.option.triviabot = ("Option_triviabot").checked;
temp.option.saveVars("options/globalmsg.txt", 0);
onClose(win);
}

function openOptionsWin() {
new GuiWindowCtrl("GlobalMsg_OptionsWin") {
visible = true;
profile = "GuiBlueWindowProfile";
extent = {250, 250};
position = {500, 300};
canMaximize = canMinimize = canResize = false;
title = true;
text = "Options";

new GuiScrollCtrl("GlobalMsg_OptionsScrl") {
position = {6, 23};
extent = {238, 200};
profile = "GuiBlueScrollProfile";
hScrollBar = vScrollBar = "alwaysOff";

thiso.eoptions = {"triviabot", "privatemessaging"};
thiso.optionspos = {10, 35};
thiso.option.loadVars("options/globalmsg.txt");


for (j = 0; j < thiso.eoptions.size(); j++) {
new GuiCheckBoxCtrl("Option_" @ thiso.eoptions[j]) {
profile = "GuiBlueCheckBoxProfile";
text = " " @ thiso.eoptions[j];
x = 6;
y = thiso.optionspos[j];
checked = makevar("thiso.option." @ thiso.eoptions[j]);
}
}

}

new GuiButtonCtrl("GlobalMsg_OptionsBtn-SavenClose") {
profile = "GuiBlueButtonProfile";
extent = {62, 21};
position = {56, 223};
text = "Save & Exit";
thiso.catchevent(name, "onAction", "SaveandClose");
}

new GuiButtonCtrl("GlobalMsg_OptionsBtn-Close") {
profile = "GuiBlueButtonProfile";
extent = {60, 21};
position = {126, 223};
text = "E x i t";
thiso.catchevent(name, "onAction", "onClose");
}
}
}


Note: This is a very quick script I made so you can GlobalChat on Client instead of being on RC. You do not require to type /npc globalmsg "text", but you do need to use quotes (this is because of the way the message system is made).

Read comments on top of script for information and help. I don't plan on releasing again until its completely done and modular for easy updates. Enjoy for now.

xXziroXx
02-02-2007, 04:58 AM
Harr harr, more "mods" for the message sys! Nice work.