IRC echo Basic Templates

rulk

  • Full Member
  • Shine Jesus Shine
  • Posts: 119
IRC echo Basic Templates
« on October 17th, 2015, 11:29 AM »Last edited on October 22nd, 2015, 12:17 PM
Hya chaps,

I have created three examples of how-to use sockets in VC:MP that connects you to a IRC network to send/receive data.

All the examples show you how-to parse the received data and get those raw IRC events like PING and 001 ( the welcome message from the IRC server ), also the IRC commands like kick/join/part etc etc.

Hopefully new scripters to the community will find them helpful.

Example One - This connects a single bot to IRC

Example Two - This connnects multiple bots to IRC

Example Three - This connects multiple bots to IRC with UserLevels


How-to Load:
Code: [Select]
function onScriptLoad( )
{
// Load the echo script
dofile( "echo.nut" );

// Call the main function to load the bot.
LoadBot();
}

How-to Send data to IRC:
Code: [Select]
function onPlayerJoin( player )
{
// Output to irc
SendToIRC( "** [" + player.ID + "] " + player + " has joined the server." );
}

Please note these just basic templates for scripters to learn from.
We are all god's children.

KAKAN

  • Wiki Contributor
  • Posts: 3,347
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

Xmair

  • Wiki Contributor
  • Posts: 871
VU Full Member | VCCNR Developer | KTB Developer | EAD Ex-Scripter

Doom_Kill3R

  • VC:MP Beta Tester
  • Infinite loops defy infinity by overflowing memory
  • Posts: 1,099
Re: IRC echo Basic Templates
« Reply #3, on October 17th, 2015, 03:11 PM »Last edited on October 17th, 2015, 03:36 PM
Rulk, Your work is clean, the thing which attracts me most. Awesome work.

Cool

  • Hero Member
  • Posts: 719

Zeeshan.Bhatti

  • Full Member
  • Posts: 213

rulk

  • Full Member
  • Shine Jesus Shine
  • Posts: 119
Re: IRC echo Basic Templates
« Reply #6, on October 22nd, 2015, 12:51 PM »
Updated and added a third example that implements UserLevels, but I recommend if you are just starting out scripting to use the first example.

Hope this helps you guys learn.

regards,


rulk
We are all god's children.

KAKAN

  • Wiki Contributor
  • Posts: 3,347
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

Doom_Kill3R

  • VC:MP Beta Tester
  • Infinite loops defy infinity by overflowing memory
  • Posts: 1,099
Re: IRC echo Basic Templates
« Reply #8, on October 22nd, 2015, 02:54 PM »
I already transfered myself to this echo script, its so neat, so understandable so easy to edit accordingly. Big thanks @rulk!

rulk

  • Full Member
  • Shine Jesus Shine
  • Posts: 119
Re: IRC echo Basic Templates
« Reply #9, on October 22nd, 2015, 06:25 PM »
Thanks chaps,

I hope adding the UserLevels didn't make it untidy. I thought people would find it useful to have though.

regards,
 
rulk
We are all god's children.

KAKAN

  • Wiki Contributor
  • Posts: 3,347
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

wilber32

  • Jr. Member
  • Posts: 56

KAKAN

  • Wiki Contributor
  • Posts: 3,347
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

kennedyarz

  • Sr. Member
  • Making American Great Again
  • Posts: 334
Re: IRC echo Basic Templates
« Reply #13, on April 15th, 2016, 09:14 PM »
añadir funciones en el main para que este funcione perfectamente:
//IRC Colours
const IRC = "#NIT"
const ICOL_WHITE    = "\x000300";
const ICOL_BLACK    = "\x000301";
const ICOL_BLUE     = "\x000302";
const ICOL_GREEN    = "\x000303";
const ICOL_RED      = "\x000304";
const ICOL_BROWN    = "\x000305";
const ICOL_PURPLE   = "\x000306";
const ICOL_ORANGE   = "\x000307";
const ICOL_YELLOW   = "\x000308";
const ICOL_LGREEN   = "\x000309";
const ICOL_CYAN     = "\x000310";
const ICOL_LCYAN    = "\x000311";
const ICOL_LBLUE    = "\x000312";
const ICOL_PINK     = "\x000313";
const ICOL_GREY     ="\x000314";
const ICOL_LGREY    = "\x000315";
const ICOL          = "\x0003";
const ICOL_BOLD     = "\x0002";
const ICOL_ULINE    = "\x0031";


function TeamidToRGB(teamid)
{
 switch (teamid)
 {
 case 0: return RGB(119, 136, 152);
 case 1: return RGB(255, 141, 19);
 case 2: return RGB(163, 73, 164);
 case 3: return RGB(32, 177, 170);
 case 4: return RGB(255, 215, 32);
 case 5: return RGB(220, 20, 59);
 case 6: return RGB(99, 139, 236);
 case 7: return RGB(255, 141, 19);
 case 8: return RGB(244, 163, 97);
 case 9: return RGB(238, 130, 239);
 case 10: return RGB(139, 69, 18);
 case 11: return RGB(240, 231, 140);
 case 12: return RGB(20, 138, 138);
 case 13: return RGB(20, 255, 127);
 case 14: return RGB(86, 107, 48);
 case 15: return RGB(25, 25, 113);
 default: return RGB(0, 0, 0);
 }
}


function GetTok(string, separator, n, ...)
{
local m = vargv.len() > 0 ? vargv[0] : n,
tokenized = split(string, separator),
text = "";
if (n > tokenized.len() || n < 1) return null;
for (; n <= m; n++)
{
text += text == "" ? tokenized[n-1] : separator + tokenized[n-1];
}
return text;
}

function GetTeamTocolor(id)
{
switch (id)
{
case 255: return "[#FFFFFF]";
case 9: return "[#FFFFFF]";
case 10: return "[#FFFFFF]";
case 2: return "[#00FFFF]";
case 3: return "[#FF69B4]";
case 4: return "[#008000]";
case 5: return "[#FFFF00]";
case 6: return "[#800080]";
case 7: return "[#AFEEEE]";
case 8: return "[#0000FF]";
default: return "[#000000]";
}
}

function NumTok(string, separator)
{
local tokenized = split(string, separator);
return tokenized.len();
}

function GetBPName(bodypart)
{
switch( bodypart )
{
case 0:return"Body";
case 1:return"Torso";
case 2:return"Left Arm";
case 3:return"Right Arm";
case 4:return"Left Leg";
case 5:return"Right Leg";
case 6:return"Head";
case 7:return"Hitting His Car";
default:return"UnKnown";
}
}
function GetBPNombre(bodypart)
{
switch( bodypart )
{
case 0:return"body";
case 1: return "Torso";
case 2: return "left arm";
case 3: return "right arm";
case 4: return "Left leg";
case 5: return "Right leg";
case 6: return "Head";
default: return "unknown";
}
}

function GetPlayer( plr )
{
    if ( plr )
    {
        if ( IsNum( plr ) )
        {
            plr = FindPlayer( plr.tointeger() );
            if ( plr ) return plr;
            else return null;
        }
       else
        {
            plr = FindPlayer( plr );
            if ( plr ) return plr;
            else return null;
        }
    }
    else return null;
}