Another great script from KuJi

. This allows the use of multiple irc chatrooms (to join) aswell as if you are staff you will be able to get an RC Tab (unclosable though - atleast for now.. I may change that sometime though**)
Anyway, don't forget to rep me

. As my rep rises, I will add more scripts to the code gallery

. Enjoy.. and if you are too use this PLEASE DO NOT TAKE MY NAME OUT. I'd prefer to keep the credit I deserve, expecially if you want updates to this

.
To open / close the program hold Shift and 1. Enjoy

.
( Also if you have a request.. forum pm me it

)
PHP Code:
// NPC Made by KuJi
/*
If you use this script you must leave my name
above aswell as in the text of each starting
window. If you do not respect this simple
rule I have I will stop releasing scripts
for the public. Thanks, KuJi aka Joey.
*/
//#CLIENTSIDE
function onCreated()
{
this.isstaff = false;
requesttext("options", "");
sendtext("irc", "login", player.nick);
onShowGUI();
}
function onShowGUI()
{
if (GIRC_Window0 != NULL)
{
GIRC_Window0.destroy();
}
new GuiWindowCtrl(GIRC_Window0)
{
profile = "GuiBlueWindowProfile";
extent = {554, 403};
position = {271, 125};
text = "IRC Chat - Made by KuJi (V 1.0)";
visible = false;
new GuiTabCtrl(GIRC_Tab)
{
profile = "GuiBlueTabProfile";
extent = {535, 25};
position = {8, 33};
horizSizing = "width";
clearrows();
}
new GuiScrollCtrl(GIRC_Scroll1)
{
profile = "GuiBlueScrollProfile";
extent = {386, 314};
position = {6, 58};
hscrollbar = "dynamic";
vscrollbar = "dynamic";
horizSizing = "width";
vertSizing = "height";
}
new GuiScrollCtrl(GIRC_Scroll2)
{
profile = "GuiBlueScrollProfile";
extent = {157, 314};
position = {391, 58};
hscrollbar = "dynamic";
vscrollbar = "dynamic";
horizSizing = "left";
vertSizing = "height";
}
new GuiTextEditCtrl(GIRC_Edit)
{
profile = GuiBlueTextEditProfile;
extent = {542, 25};
position = {6, 372};
text = "";
historysize = 50;
horizSizing = "width";
vertSizing = "top";
}
}
}
function GIRC_Tab.onSelect(tabid, tabtext, tabindex)
{
for (temp.var: GIRC_Tab.rows)
{
if (temp.var.text == tabtext)
{
temp.textobj = makevar("GIRC_Text_" @ temp.var.tabid);
temp.listobj = makevar("GIRC_List_" @ temp.var.tabid);
temp.textobj.visible = true;
temp.listobj.visible = true;
break;
}
}
}
function GIRC_Tab.onDeselect(tabid, tabtext, tabindex)
{
for (temp.var: GIRC_Tab.rows)
{
if (temp.var.text == tabtext)
{
temp.textobj = makevar("GIRC_Text_" @ temp.var.tabid);
temp.listobj = makevar("GIRC_List_" @ temp.var.tabid);
temp.textobj.visible = false;
temp.listobj.visible = false;
break;
}
}
}
function GIRC_Edit.onAction()
{
if (GIRC_Edit.text.starts("/join"))
{
sendtext("irc", "join", GIRC_Edit.text.substring(6));
}
elseif (GIRC_Edit.text.starts("/part"))
{
sendtext("irc", "part", GIRC_Edit.text.substring(6));
}
elseif (GIRC_Edit.text.starts("/"))
{
onAddMsg({"unknown or incomplete command, type /help for more info", GIRC_Tab.getselectedtext() , "unknown or incomplete command, type /help for more info"});
}
elseif (GIRC_Edit.text != NULL)
{
if (GIRC_Tab.getselectedtext() == "RemoteControl")
{
sendtorc(GIRC_Edit.text);
}
else
{
sendtext("irc", "privmsg", {GIRC_Tab.getselectedtext(), GIRC_Edit.text});
}
}
GIRC_Edit.text = "";
}
function onReceiveText(texttype, textoptions, textlines)
{
if (texttype == "options")
{
this.isstaff = true;
requesttext("clientrc", 1);
onJoinChat("RemoteControl");
onTimeout();
}
elseif (texttype == "irc")
{
switch (textoptions)
{
case "addchanneluser":
{
// Add Player to Channel
temp.tfound = onFindTab(textlines[0]);
if (temp.tfound >= 0)
{
temp.listobj = makevar("GIRC_List_" @ temp.tfound);
temp.listobj.addrow(this.newUser++, textlines[1]);
}
break;
}
case "deletechanneluser":
{
// Remove Player from Channel
temp.tfound = onFindTab(textlines[0]);
if (temp.tfound >= 0)
{
temp.listobj = makevar("GIRC_List_" @ temp.tfound);
temp.listobj.removerow(temp.listobj.findtext(textlines[1]));
}
break;
}
case "join":
{
// Join Channel
onJoinChat(textlines[0]);
break;
}
case "part":
{
// Leave Channel
onLeaveChat(textlines[0]);
break;
}
case "privmsg":
{
// Get Message (Regular Message)
onAddMsg(textlines);
break;
}
}
}
}
function onRCChat(text)
{
onAddMsg({text.substring(0, text.pos(":")), "RemoteControl", text.substring(text.pos(":") + 1)});
}
function onAddMsg(temp.tlines)
{
temp.tfound = onFindTab(temp.tlines[1]);
if (temp.tfound >= 0)
{
if (textlines[0].substring(0, temp.tlines[0].pos("_")) == player.account)
{
temp.color = "FF0000";
}
else
{
temp.color = "00FF00";
}
temp.textobj = makevar("GIRC_Text_" @ temp.tfound);
temp.textobj.text = format("%s<br><font color=#%s>%s:</font> %s", temp.textobj.text, temp.color, temp.tlines[0], temp.tlines[2]);
}
}
function onJoinChat(newChan)
{
// Add to Tab
with (GIRC_Tab.addrow(thiso.ircChat++, newChan))
{
this.tabid = thiso.ircChat;
GIRC_Tab.setselectedbyid(this.id);
}
// Create Text
with (GIRC_Scroll1)
{
new GuiMLTextCtrl("GIRC_Text_" @ thiso.ircChat)
{
profile = GuiBlueMLTextProfile;
extent = {375, 120};
position = {3, 2};
text = "<font color=#FF0000 size=15><b><u>Graal IRC V1.0 Scripted by Joey. Last updated on October 02, 2006</u></b></font>";
wordwrap = true;
}
}
// Create List
with (GIRC_Scroll2)
{
new GuiTextListCtrl("GIRC_List_" @ thiso.ircChat)
{
profile = GuiBlueTextListProfile;
position = {0, 0};
width = 140;
fitparentwidth = true;
clearrows();
addrow(0, player.account);
setSelectedRow(1);
}
}
}
function onLeaveChat(newChan)
{
temp.tfound = onFindTab(newChan, true);
if (temp.tfound[0] >= 0)
{
temp.listobj = makevar("GIRC_List_" @ temp.tfound[1]);
temp.textobj = makevar("GIRC_Text_" @ temp.tfound[1]);
temp.textobj.text = "";
temp.listobj.destroy();
temp.textobj.destroy();
GIRC_Tab.removerowbyid(temp.tfound[0]);
}
}
function onFindTab(ircTab, ircType)
{
for (temp.var: GIRC_Tab.rows)
{
if (temp.var.text == ircTab)
{
if (ircType != NULL)
{
return {temp.var.id, temp.var.tabid};
}
else
{
return temp.var.tabid;
}
}
}
return -1;
}
function onFindRCS()
{
temp.tfound = onFindTab("RemoteControl");
if (temp.tfound >= 0)
{
temp.newUser = 0;
temp.listobj = makevar("GIRC_List_" @ temp.tfound);
temp.listobj.clearrows();
for (temp.var: allplayers)
{
if (!temp.var.account.starts("irc") && temp.var.level == "" && temp.var.account != "(npcserver)")
{
temp.listobj.addrow(temp.newUser++, temp.var.account);
}
}
}
}
function onTimeout()
{
onFindRCS();
setTimer(5);
}
function onKeyPressed(keycode, keychar)
{
if (keycode == 305)
{
GIRC_Window0.visible = !GIRC_Window0.visible;
}
}
Commands:
/join #CHANNEL_NAME
/part #CHANNEL_NAME