Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   IRC Chat W/ RC Chat (If Staff) (https://forums.graalonline.com/forums/showthread.php?t=69121)

KuJi 10-02-2006 09:19 PM

IRC Chat W/ RC Chat (If Staff)
 
1 Attachment(s)
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   = {554403};
    
position = {271125};

    
text     "IRC Chat - Made by KuJi (V 1.0)";
    
visible  false;

    new 
GuiTabCtrl(GIRC_Tab)
    {
      
profile "GuiBlueTabProfile";
      
extent = {53525};
      
position = {833};
      
      
horizSizing "width";
      
      
clearrows();
    }
    
    new 
GuiScrollCtrl(GIRC_Scroll1)
    {
      
profile     "GuiBlueScrollProfile";
      
extent      = {386314};
      
position    = {658};
      
      
hscrollbar  "dynamic";
      
vscrollbar  "dynamic";
      
      
horizSizing "width";
      
vertSizing  "height";
    }
    
    new 
GuiScrollCtrl(GIRC_Scroll2)
    {
      
profile     "GuiBlueScrollProfile";
      
extent      = {157314};
      
position    = {39158};
      
      
hscrollbar  "dynamic";
      
vscrollbar  "dynamic";
      
      
horizSizing "left";
      
vertSizing  "height";
    }
    
    new 
GuiTextEditCtrl(GIRC_Edit)
    {
      
profile GuiBlueTextEditProfile;
      
extent  = {54225};
      
position = {6372};
      
      
text "";
      
      
historysize 50;
      
horizSizing "width";
      
vertSizing  "top";
    }
  }
}

function 
GIRC_Tab.onSelect(tabidtabtexttabindex)
{
  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(tabidtabtexttabindex)
{
  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(texttypetextoptionstextlines)
{
  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(0text.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(0temp.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.texttemp.colortemp.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   = {375120};
      
position = {32};
      
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       = {00};
      
width          140;
      
fitparentwidth true;
    
      
clearrows();
      
addrow(0player.account);
      
setSelectedRow(1);
    }
  }
}

function 
onLeaveChat(newChan)
{
  
temp.tfound onFindTab(newChantrue);
  
  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(ircTabircType)
{
  for (
temp.var: GIRC_Tab.rows)
  {
    if (
temp.var.text == ircTab)
    {
      if (
ircType != NULL)
      {
        return {
temp.var.idtemp.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(keycodekeychar)
{
  if (
keycode == 305)
  {
    
GIRC_Window0.visible = !GIRC_Window0.visible;
  }


Commands:
/join #CHANNEL_NAME
/part #CHANNEL_NAME

Twinny 10-03-2006 04:02 AM

Quote:

Originally Posted by KuJi (Post 1225095)
Anyway, don't forget to rep me ;). As my rep rises, I will add more scripts to the code gallery ;)

Should add scripts for the general advancement of graal - not for personal rep points >_<

Anywho. Only 1 problem I have found, it shows global buddies in the RC playerlist =(

KuJi 10-03-2006 04:39 AM

Quote:

Originally Posted by Twinny (Post 1225335)
Should add scripts for the general advancement of graal - not for personal rep points >_<

Anywho. Only 1 problem I have found, it shows global buddies in the RC playerlist =(

And it also doesn't show player rcs, I'll fix soon.

Moondeath_2 10-03-2006 04:50 PM

Quote:

Originally Posted by Twinny (Post 1225335)
Should add scripts for the general advancement of graal - not for personal rep points >_<

Anywho. Only 1 problem I have found, it shows global buddies in the RC playerlist =(

You should post some cool stuff. ;)

KuJi 10-03-2006 09:13 PM

Quote:

Originally Posted by Moondeath_2 (Post 1225441)
You should post some cool stuff. ;)

He's just jeolous cuz I know what teh community likes ;).

Besides, I only made this becuz Shrobo went COOL @ your irc chat =( (which was soo basic)

zephirot 10-03-2006 09:14 PM

Nice, but whats up with the pokemon thing in the bacground?

KuJi 10-03-2006 09:15 PM

Quote:

Originally Posted by zephirot (Post 1225549)
Nice, but whats up with the pokemon thing in the bacground?

;).. I wanna be the very best.

Just don't worry about that for now ;P


All times are GMT +2. The time now is 08:17 AM.

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