[HELP] IRC Filterscript (Sneaky.'s)
#1

How do I set up this IRC system to work with my server?
http://forum.sa-mp.com/index.php?topic=83539.0

What exactly do I have to edit to make it work with my server?

I edited
pawn Код:
#define IRC_SERVER           ""     // IRC Server (e.g irc.gtanet.com)
#define IRC_PORT        6667    // Set the IRC port (default 6667)
and
pawn Код:
#define IRC_ECHO_CHAN      "#channel"
Please help
Reply
#2

Define IRC server and your own channel-name.
Reply
#3

I did. Lol
Reply
#4

Please help, its still not working.

(Sorry for double post, edit button isn't working form me :S)
Reply
#5

Try pasting the code you have set up at the moment then someone can diagnose the problem.
Reply
#6

pawn Код:
#include <a_samp>

/*

    Simple irc echo filterscript
    Brought to you by [NB]Sneaky

    http://www.99B1aZed.com
   
http://www.sneakyhost.net[url=http://]

    Player Commands:

    !imsg       <send message to server>
    !igetid     <get a players id based on nickname>

    Admin Commands:

    !iban       <ban a player with optional reason>
    !ikick      <kick a player with optional reason>
    !islap      <slap a player with optional reason>
    !ikill      <kill a player with optional reason>
    !isay       <send message to the server as admin>
    !ipause     <pause the echo, !pause again to unpause>

    DO NOT REMOVE CREDITS!
    That's all I ask.

*/


#define irccmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (irccmd_%1(conn,channel,user,"")))||(((%3)[(%2) + 1] == 32) && (irccmd_%1(conn,channel,user,(%3)[(%2) + 2]))))) return 1

// Setup settings here

#define IRC_SERVER          "irc.gtanet.com"     // IRC Server (e.g irc.gtanet.com)
#define IRC_PORT        6667    // Set the IRC port (default 6667)

// Uncomment line 39 if you want to use 2 bots, uncomment line 40 if you want to use 3 bots
//#define IRC_AMOUNT1     true
//#define IRC_AMOUNT2     true
//#define IRC_AMOUNT3     true

// Put the names of your irc bot's here (Note: not every bot can have the same name)
#define IRC_ECHO_BOT1   ""
#define IRC_ECHO_BOT2   ""
#define IRC_ECHO_BOT3   ""

// #channel is the channel you want to echo in game chat in, change it.
#define IRC_ECHO_CHAN   "#usftdm"

// If your bot names are registered put a password here to identify them with
#define IRC_PASSWORD        ""

// Set the IRC join delay (1000 = 1 second), set to 0 if you dont want to use it
// (IF bot has a vHost then set this to 5000 ELSE it wont show the vHost on channel join)
#define IRC_JOIN_DELAY   0

// PRETTY SELF EXPLANARY

#define IRC_QUIT_MSG    "Quiting"
#define IRC_AUTH_MSG    "You are not authorized!"
#define IRC_INTI_MSG1    "Your custom initialize message here :)"
#define IRC_INTI_MSG2    "Your custom initialize message here :)"
#define IRC_INTI_MSG3    "Your custom initialize message here :)"

native ircGetUserLevel(conn, channel[], user[], dest[]);
native ircGetUserList(conn, channel[], dest[], size);
native ircSetMode(conn, channel[], modes[], nicks[]);
native ircConnect(server[], port, user[]);
native ircSay(conn, channel[], message[]);
native ircSendRawData(conn, rawdata[]);
native ircJoinChan(conn, channel[]);
native ircPartChan(conn, channel[]);
native ircDisconnect(conn);
native ircPollEvents();

forward ircOnUserSay(conn, channel[], user[], message[]);
forward ircOnUserPart(conn, channel[], user[]);
forward ircOnUserJoin(conn, channel[], user[]);
forward Float:GetDistanceBetweenPlayers(p1,p2);
forward EchoConnectionCheck();
forward IrcPollEventsTimer();
forward DelayedChannelJoin();
forward ircOnConnect(conn);
forward IrcSay(Message[]);

stock
    EchoConnection[3],
    EchoBot = 0,
    ConnE,
    Echo_Paused = 0;

// Simon
new aWeaponNames[][32] = {
    {"Unarmed (Fist)"}, // 0
    {"Brass Knuckles"}, // 1
    {"Golf Club"}, // 2
    {"Night Stick"}, // 3
    {"Knife"}, // 4
    {"Baseball Bat"}, // 5
    {"Shovel"}, // 6
    {"Pool Cue"}, // 7
    {"Katana"}, // 8
    {"Chainsaw"}, // 9
    {"Purple Dildo"}, // 10
    {"Big White Vibrator"}, // 11
    {"Medium White Vibrator"}, // 12
    {"Small White Vibrator"}, // 13
    {"Flowers"}, // 14
    {"Cane"}, // 15
    {"Grenade"}, // 16
    {"Teargas"}, // 17
    {"Molotov"}, // 18
    {" "}, // 19
    {" "}, // 20
    {" "}, // 21
    {"Colt 45"}, // 22
    {"Colt 45 (Silenced)"}, // 23
    {"Desert Eagle"}, // 24
    {"Normal Shotgun"}, // 25
    {"Sawnoff Shotgun"}, // 26
    {"Combat Shotgun"}, // 27
    {"Micro Uzi (Mac 10)"}, // 28
    {"MP5"}, // 29
    {"AK47"}, // 30
    {"M4"}, // 31
    {"Tec9"}, // 32
    {"Country Rifle"}, // 33
    {"Sniper Rifle"}, // 34
    {"Rocket Launcher"}, // 35
    {"Heat-Seeking Rocket Launcher"}, // 36
    {"Flamethrower"}, // 37
    {"Minigun"}, // 38
    {"Satchel Charge"}, // 39
    {"Detonator"}, // 40
    {"Spray Can"}, // 41
    {"Fire Extinguisher"}, // 42
    {"Camera"}, // 43
    {"Night Vision Goggles"}, // 44
    {"Infrared Vision Goggles"}, // 45
    {"Parachute"}, // 46
    {"Fake Pistol"} // 47
};

new aDisconnectNames[][16] = {
    {"Timeout"}, // 0
    {"Leaving"}, // 1
    {"Kicked"} // 2
};

public OnFilterScriptInit()
{
    print("\t============================================");
    print("\tIRC Filterscript");
    print("\tBy: Sneaky");
    print("\t-");
    print("\tLoaded..");
    print("\t============================================");
    #if defined IRC_AMOUNT1
    {
        EchoConnection[0] = ircConnect(IRC_SERVER, IRC_PORT, IRC_ECHO_BOT1);
    }
    #endif
    #if defined IRC_AMOUNT2
    {
        EchoConnection[1] = ircConnect(IRC_SERVER, IRC_PORT, IRC_ECHO_BOT2);
    }
    #endif
    #if defined IRC_AMOUNT3
    {
        EchoConnection[2] = ircConnect(IRC_SERVER, IRC_PORT, IRC_ECHO_BOT3);
    }
    #endif
    return 1;
}

public OnFilterScriptExit()
{
    print("\t============================================");
    print("\tIRC Filterscript");
    print("\tBy: Sneaky");
    print("\t-");
    print("\tLoaded..");
    print("\t============================================");
    #if defined IRC_AMOUNT1
    {
        ircSendRawData(EchoConnection[0], "QUIT "IRC_QUIT_MSG"");
    }
    #endif
    #if defined IRC_AMOUNT2
    {
        ircSendRawData(EchoConnection[1], "QUIT "IRC_QUIT_MSG"");
    }
    #endif
    #if defined IRC_AMOUNT3
    {
        ircSendRawData(EchoConnection[2], "QUIT "IRC_QUIT_MSG"");
    }
    #endif
    return 1;
}

public ircOnConnect(conn)
{
  SetTimer("DelayedChannelJoin",IRC_JOIN_DELAY,0);
  SetTimer("IrcPollEventsTimer", 500, 1);

    #if defined IRC_AMOUNT1
    {
    ircSendRawData(EchoConnection[0], "PRIVMSG NickServ :IDENTIFY "IRC_PASSWORD" ");
    }
    #endif
    #if defined IRC_AMOUNT2
    {
    ircSendRawData(EchoConnection[1], "PRIVMSG NickServ :IDENTIFY "IRC_PASSWORD" ");
  }
  #endif
    #if defined IRC_AMOUNT3
    {
    ircSendRawData(EchoConnection[2], "PRIVMSG NickServ :IDENTIFY "IRC_PASSWORD" ");
  }
  #endif
  return 1;
}

public IrcPollEventsTimer()
{
  ircPollEvents();
    return 1;
}

public DelayedChannelJoin()
{
    #if defined IRC_AMOUNT1
    {
    ircJoinChan(EchoConnection[0], IRC_ECHO_CHAN);
    IrcSay("4"IRC_INTI_MSG1"");
  }
  #endif
    #if defined IRC_AMOUNT2
    {
    ircJoinChan(EchoConnection[1], IRC_ECHO_CHAN);
    IrcSay("4"IRC_INTI_MSG2"");
  }
  #endif
    #if defined IRC_AMOUNT3
    {
    ircJoinChan(EchoConnection[2], IRC_ECHO_CHAN);
    IrcSay("4"IRC_INTI_MSG3"");
  }
  #endif
  return 1;
}

public IrcSay(Message[]) return ircSay(BotSwitcher(), IRC_ECHO_CHAN, Message);

public OnPlayerText(playerid, text[])
{
    new
        tString[128],PlayerName[24];

    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));

    if(Echo_Paused == 0)
    {
        format(tString, sizeof(tString), "12[%d]7 %s:0 %s", playerid, PlayerName, text);
        IrcSay(tString);
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    new
      tString[128],pName[128],kName[128];

    GetPlayerName(killerid, kName,sizeof(kName));
    GetPlayerName(playerid, pName,sizeof(pName));

    if(Echo_Paused == 0)
    {
        if(reason == 255)
        {
          format(tString,sizeof(tString),"3%s died.",pName);
          IrcSay(tString);
        }
        else
        {
            format(tString,sizeof(tString),"3%s was killed by %s (Weapon: %s - Distance: %.0f ft)",pName,kName,aWeaponNames[reason],GetDistanceBetweenPlayers(playerid,killerid));
            IrcSay(tString);
        }
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    new
        tString[64],PlayerName[24];

    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    if(Echo_Paused == 0)
    {

        format(tString, sizeof(tString), "3%s joined the server.", PlayerName);
        IrcSay(tString);
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new
        tString[64],PlayerName[24];

    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));

    if(Echo_Paused == 0)
    {
        format(tString, sizeof(tString), "3%s has left the server. (%s)", PlayerName, aDisconnectNames[reason]);
        IrcSay(tString);
    }
    return 1;
}


stock BotSwitcher()
{
    #if defined IRC_AMOUNT1
    {
        switch(EchoBot)
        {
          case 0:
            {
              ConnE = EchoConnection[0];
              EchoBot = 0;
            }
        }
    }
    #endif
    #if defined IRC_AMOUNT2
    {
        switch(EchoBot)
        {
          case 0:
            {
              ConnE = EchoConnection[0];
              EchoBot = 1;
            }
            case 1:
            {
              ConnE = EchoConnection[1];
                EchoBot = 0;
            }
        }
    }
    #endif
    #if defined IRC_AMOUNT3
    {
        switch(EchoBot)
        {
          case 0:
            {
              ConnE = EchoConnection[0];
              EchoBot = 1;
            }
            case 1:
            {
              ConnE = EchoConnection[1];
                EchoBot = 2;
            }
            case 2:
            {
              ConnE = EchoConnection[2];
                EchoBot = 0;
            }
        }
    }
    #endif
    return ConnE;
}

stock ircIsOp(conn,channel[],user[])
{
    new
        ircLevel[4];

    ircGetUserLevel(conn, channel, user, ircLevel);

    if(!strcmp(ircLevel, "~", true,1) || !strcmp(ircLevel, "&", true,1) || !strcmp(ircLevel, "@", true,1)) return 1;
    return 0;
}

public ircOnUserSay(conn, channel[], user[], message[])
{
    if(message[0] != &#39;!') return 1;

    // Admin (+o / @ | +qo / ~ | +a / &) commands here
    irccmd(ipause,6,conn,channel,user,message);
    irccmd(ikick,5,conn,channel,user,message);
    irccmd(ikill,5,conn,channel,user,message);
    irccmd(islap,5,conn,channel,user,message);
    irccmd(isay,4,conn,channel,user,message);
    irccmd(iban,4,conn,channel,user,message);

    // Player (N/A | +v | +h / %) commands here
    irccmd(imsg,4,conn,channel,user,message);
    irccmd(igetid,6,conn,channel,user,message);

    return 1;
}

// Player Commands

irccmd_imsg(conn, channel[], user[], params[])
{
  #pragma unused conn,channel

  new
    tString[128];

    if(!strlen(params)) return IrcSay("USAGE: !imsg <message>");

    format(tString,sizeof(tString), ">> Player from IRC %s: %s", user, params);
    SendClientMessageToAll(0xFFFFFFAA, tString);

    IrcSay(tString);
    return 1;
}

irccmd_igetid(conn, channel[], user[], params[])
{
    #pragma unused conn,channel,user

  new
        idx,tString[128],
        param[20], PlayerName[24];

  param = strtok(params, idx);

  if (!strlen(param))
    return IrcSay ("USAGE: !igetid <nickname>");

  new
        count = 0;

  for (new i=0; i<GetMaxPlayers() && count<10; i++)
  {
    if (IsPlayerConnected(i))
        {
      GetPlayerName(i, PlayerName, sizeof(PlayerName));
      for (new j=0, k=(strlen(PlayerName)-strlen(param)); j<=k; j++)
      {
        if (strcmp(param, PlayerName[j], true, strlen(param)) == 0)
                {
          format(tString, sizeof(tString), "%s%s(%d), ", tString, PlayerName, i);
          count++;
          break;
        }
      }
    }
  }
  if (strlen(tString))
    {
    format(tString, sizeof(tString), "Matches: %s", tString);
    tString[strlen(tString) - 2] = 0;
  }
    else
    {
    format(tString, sizeof(tString), "No matches for: %s", param);
  }
  IrcSay(tString);
  return 1;
}

// Admin Commands

irccmd_isay(conn, channel[], user[], params[])
{
  if(!ircIsOp(conn,channel,user)) return IrcSay(""IRC_AUTH_MSG"");

  new
    tString[128];

    if(!strlen(params)) return IrcSay("USAGE: !imsg <message>");

    format(tString,sizeof(tString), ">> Admin from IRC %s: %s", user, params);
    SendClientMessageToAll(0xFF0000AA, tString);

    IrcSay(tString);
    return 1;
}

irccmd_ipause(conn, channel[], user[], params[])
{
  #pragma unused params

  if(!ircIsOp(conn,channel,user)) return IrcSay(""IRC_AUTH_MSG"");

    if(Echo_Paused == 0)
    {
        IrcSay("Paused.");
        Echo_Paused = 1;
    }
    else if(Echo_Paused == 1)
    {
      IrcSay("Unpaused.");
      Echo_Paused = 0;
    }
    return 1;
}

irccmd_iban(conn, channel[], user[], params[])
{
  if(!ircIsOp(conn,channel,user)) return IrcSay(""IRC_AUTH_MSG"");

    new
        ID = strval(params),tString[128],
        Reason[64],PlayerName[24];

    GetPlayerName(ID,PlayerName,sizeof(PlayerName));

    if(!IsPlayerConnected(ID))
      return IrcSay ("USAGE: !iban <playerid> <reason>");

    if(sscanf(params, "dz", ID, Reason))
        return IrcSay ("USAGE: !iban <playerid> <reason>");

    format(tString,sizeof(tString),"Admin %s (ID: -1) banned %s (ID:%d) Reason: %s",user,PlayerName,ID,Reason);
    SendClientMessageToAll(0xFF0000AA, tString);
    IrcSay(tString);

    BanEx(ID, Reason);
    return 1;
}

irccmd_ikick(conn, channel[], user[], params[])
{
  if(!ircIsOp(conn,channel,user)) return IrcSay(""IRC_AUTH_MSG"");

    new
        ID = strval(params),tString[128],
        Reason[64],PlayerName[24];

    GetPlayerName(ID,PlayerName,sizeof(PlayerName));

    if(!IsPlayerConnected(ID))
      return IrcSay ("USAGE: !iban <playerid> <reason>");

    if(sscanf(params, "dz", ID, Reason))
        return IrcSay ("USAGE: !ikick <playerid> <reason>");

    format(tString,sizeof(tString),"Admin %s (ID: -1) kicked %s (ID:%d) Reason: %s",user,PlayerName,ID,Reason);
    SendClientMessageToAll(0xFF0000AA, tString);
    IrcSay(tString);

    Kick(ID);
    return 1;
}

irccmd_ikill(conn, channel[], user[], params[])
{
  if(!ircIsOp(conn,channel,user)) return IrcSay(""IRC_AUTH_MSG"");

    new
        ID = strval(params),tString[128],
        Reason[64],PlayerName[24];

    GetPlayerName(ID,PlayerName,sizeof(PlayerName));

    if(!IsPlayerConnected(ID))
      return IrcSay ("USAGE: !ikill <playerid> <reason>");

    if(sscanf(params, "dz", ID, Reason))
        return IrcSay ("USAGE: !ikill <playerid> <reason>");

    format(tString,sizeof(tString),"Admin %s (ID: -1) killed %s (ID:%d) Reason: %s",user,PlayerName,ID,Reason);
    SendClientMessageToAll(0xFF0000AA, tString);
    IrcSay(tString);

    SetPlayerHealth(ID,0);
    return 1;
}

irccmd_islap(conn, channel[], user[], params[])
{
  if(!ircIsOp(conn,channel,user)) return IrcSay(""IRC_AUTH_MSG"");

    new
        ID = strval(params),tString[128],
        Reason[64],PlayerName[24];

    GetPlayerName(ID,PlayerName,sizeof(PlayerName));

    if(!IsPlayerConnected(ID))
      return IrcSay ("USAGE: !islap <playerid> <reason>");

    if(sscanf(params, "dz", ID, Reason))
        return IrcSay ("USAGE: !islap <playerid> <reason>");

    format(tString,sizeof(tString),"Admin %s (ID: -1) slapped %s (ID:%d) Reason: %s",user,PlayerName,ID,Reason);
    SendClientMessageToAll(0xFF0000AA, tString);
    IrcSay(tString);

    new Float:x,Float:y,Float:z;
    GetPlayerPos(ID, x, y, z);
    SetPlayerPos(ID, x, y, z+10);
    return 1;
}

stock sscanf(string[], format[], {Float,_}:...)
{
    new
        formatPos = 0,
        stringPos = 0,
        paramPos = 2,
        paramCount = numargs();
    while (paramPos < paramCount && string[stringPos])
    {
        switch (format[formatPos++])
        {
            case &#39;\0':
            {
                return false;
            }
            case &#39;i', 'd':
            {
                new
                    neg = 1,
                    num = 0,
                    ch = string[stringPos];
                if (ch == &#39;-')
                {
                    neg = -1;
                    ch = string[++stringPos];
                }
                do
                {
                    stringPos++;
                    if (ch >= &#39;0' && ch <= '9')
                    {
                        num = (num * 10) + (ch - &#39;0');
                    }
                    else
                    {
                        return true;
                    }
                }
                while ((ch = string[stringPos]) && ch != &#39; ');
                setarg(paramPos, 0, num * neg);
            }
            case &#39;h', 'x':
            {
                new
                    ch,
                    num = 0;
                while ((ch = string[stringPos++]))
                {
                    switch (ch)
                    {
                        case &#39;x', 'X':
                        {
                            num = 0;
                            continue;
                        }
                        case &#39;0' .. '9':
                        {
                            num = (num << 4) | (ch - &#39;0');
                        }
                        case &#39;a' .. 'f':
                        {
                            num = (num << 4) | (ch - (&#39;a' - 10));
                        }
                        case &#39;A' .. 'F':
                        {
                            num = (num << 4) | (ch - (&#39;A' - 10));
                        }
                        case &#39; ':
                        {
                            break;
                        }
                        default:
                        {
                            return true;
                        }
                    }
                }
                setarg(paramPos, 0, num);
            }
            case &#39;c':
            {
                setarg(paramPos, 0, string[stringPos++]);
            }
            case &#39;f':
            {
              // Secret message, if you see this: HELLO!
                new tmp[25];
                strmid(tmp, string, stringPos, stringPos+sizeof(tmp)-2);
                setarg(paramPos, 0, _:floatstr(tmp));
            }
            case &#39;s', 'z':
            {
                new
                    i = 0,
                    ch;
                if (format[formatPos])
                {
                    while ((ch = string[stringPos++]) && ch != &#39; ')
                    {
                        setarg(paramPos, i++, ch);
                    }
                    if (!i) return true;
                }
                else
                {
                    while ((ch = string[stringPos++]))
                    {
                        setarg(paramPos, i++, ch);
                    }
                }
                stringPos--;
                setarg(paramPos, i, &#39;\0');
            }
            default:
            {
                continue;
            }
        }
        while (string[stringPos] && string[stringPos] != &#39; ')
        {
            stringPos++;
        }
        while (string[stringPos] == &#39; ')
        {
            stringPos++;
        }
        paramPos++;
    }
    while (format[formatPos] == &#39;z') formatPos++;
    return format[formatPos];
}

strtok(const string[], &index)
{
  new
        length = strlen(string);


  while ((index < length) && (string[index] <= &#39; '))
  {
    index++;
  }

  new
        offset = index,
    result[20];

  while ((index < length) && (string[index] > &#39; ') && ((index - offset) < (sizeof(result) - 1)))
  {
    result[index - offset] = string[index];
    index++;
  }

  result[index - offset] = EOS;
  return result;
}

public Float:GetDistanceBetweenPlayers(p1,p2)
{
    new
        Float:Pos[6];

    if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
    {
        return -1.00;
    }

    GetPlayerPos(p1,Pos[0],Pos[1],Pos[2]);
    GetPlayerPos(p2,Pos[3],Pos[4],Pos[5]);
    return floatsqroot(floatpower(floatabs(floatsub(Pos[3],Pos[0])),2)+floatpower(floatabs(floatsub(Pos[4],Pos[1])),2)+floatpower(floatabs(floatsub(Pos[5],Pos[2])),2));
}
Thanks
Reply
#7

Well, just having a quick look at that code I can see that you haven't set any bot names or uncommented a line to say how many bots you want to use. The server/port looks to be set up correctly so I believe the problem is the name/bot # selection.
Reply
#8

I don't have any bots. xD I just got IRC so I'm not too good with it. Can I just use my Username and pass as the bot?
Reply
#9

Replace the lines:

Код:
// Put the names of your irc bot's here (Note: not every bot can have the same name)
#define IRC_ECHO_BOT1  	""
#define IRC_ECHO_BOT2  	""
#define IRC_ECHO_BOT3  	""
with

Код:
// Put the names of your irc bot's here (Note: not every bot can have the same name)
#define IRC_ECHO_BOT1  	"usftdm1"
#define IRC_ECHO_BOT2  	"usftdm2"
#define IRC_ECHO_BOT3  	"usftdm3"
then replace

Код:
// Uncomment line 39 if you want to use 2 bots, uncomment line 40 if you want to use 3 bots
//#define IRC_AMOUNT1     true
//#define IRC_AMOUNT2     true
//#define IRC_AMOUNT3     true
with

Код:
// Uncomment line 39 if you want to use 2 bots, uncomment line 40 if you want to use 3 bots
//#define IRC_AMOUNT1     true
//#define IRC_AMOUNT2     true
#define IRC_AMOUNT3     true
In theory, if those are the only two errors; the echo should work.
Reply
#10

Hmm, Still doesn't seem to work :S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)