Vice City: Multiplayer

Server Development => Scripting and Server Management => Script Showroom => Topic started by: rulk on Oct 17, 2015, 10:29 AM

Title: IRC echo Basic Templates
Post by: rulk on Oct 17, 2015, 10:29 AM
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 (http://files.thijn.ovh/download/1bfea55d56956a94b8aebf04e04d56bf/echo.nut)

Example Two - This connnects multiple bots to IRC (http://files.thijn.ovh/download/09891e9c05308d4fc9bab0ac1bc5e677/echo.multi.nut)

Example Three - This connects multiple bots to IRC with UserLevels (http://files.thijn.ovh/download/1d0258f8235437b01af1f188f78882e7/echo.multi.userlevels.nut)


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

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

How-to Send data to IRC:
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.
Title: Re: IRC echo Basic Templates
Post by: KAKAN on Oct 17, 2015, 11:08 AM
Nice work!
I like that multiple bot system tho!
Keep it up!
Title: Re: IRC echo Basic Templates
Post by: Xmair on Oct 17, 2015, 11:10 AM
Keep the good work up, You're heaven to newbies!
Title: Re: IRC echo Basic Templates
Post by: DizzasTeR on Oct 17, 2015, 02:11 PM
Rulk, Your work is clean, the thing which attracts me most. Awesome work.
Title: Re: IRC echo Basic Templates
Post by: Cool on Oct 17, 2015, 05:12 PM
nice work
Title: Re: IRC echo Basic Templates
Post by: SAzEe21 on Oct 17, 2015, 08:19 PM
Quote from: Doom_Killer on Oct 17, 2015, 02:11 PMRulk, Your work is clean, the thing which attracts me most. Awesome work.


Keep it up..
Title: Re: IRC echo Basic Templates
Post by: rulk on Oct 22, 2015, 11:51 AM
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
Title: Re: IRC echo Basic Templates
Post by: KAKAN on Oct 22, 2015, 01:21 PM
Nice!
It would help me a lot.
Title: Re: IRC echo Basic Templates
Post by: DizzasTeR on Oct 22, 2015, 01:54 PM
I already transfered myself to this echo script, its so neat, so understandable so easy to edit accordingly. Big thanks @rulk!
Title: Re: IRC echo Basic Templates
Post by: rulk on Oct 22, 2015, 05: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
Title: Re: IRC echo Basic Templates
Post by: KAKAN on Oct 23, 2015, 04:28 PM
Those are pretty helpful tho,
Nice work.!
Keep it up!
Title: Re: IRC echo Basic Templates
Post by: wilber32 on Dec 07, 2015, 01:03 AM
Nice friend
Title: Re: IRC echo Basic Templates
Post by: KAKAN on Dec 07, 2015, 08:40 AM
Quote from: wilber32 on Dec 07, 2015, 01:03 AMNice friend

Nice bump too, friend.
Title: Re: IRC echo Basic Templates
Post by: kennedyarz on Apr 15, 2016, 08: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;
}