arrow_upward

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to add IRC System in sa-mp gamemode!
#1
Adding IRC to the gamemode
We will:

* The Plugin and Include File (http://forum.sa-mp.com/showthread.php?t=98803)
* My Own IRC System (http://forum.sa-mp.com/showthread.php?t=615893) - Ultraz IRC System


Let's Get Started!


At the includes part you'll add this to include the irc in the script

#include <irc>


Now to contain the bots 
This will be the name of your bot so when any guest joins your irc channel will find the bot with this name


#define BOT_1_NICKNAME "1stBot"

This for the first bot too, when the guest click on 'who is' or use /whois command on irc will get these info


#define BOT_1_REALNAME "My 1st Bot"
#define BOT_1_USERNAME "1stBOT"

[Important] Now lets set up the connection of irc network,channel,etc.
First we must register the channel we want in any network (I prefer pool.irc.tl [irc.tl] )
You'll go to the channel you want then login/identify with your nickname then use the command of:
/cs register #yourchannel it will give you the owner rank on IRC



#define IRC_SERVER "pool.irc.tl"
#define IRC_PORT (6667) // default port of most of IRC Networks 
#define IRC_CHANNEL "#yourchannel"

Lets end defines part

You can connect 5 bots in the IRC Channel, but my opinion to make them 2 only, even if you have 100+ players in your samp server 2 bots will be enough


#define MAX_BOTS (1)



Codes of connecting Bots


This is getting the bots id and grouping them, in our case only 1 bot, gBot is for ex. I used it on Ultraz IRC System.


new gBotID[MAX_BOTS], gGroupID;


OnFilterScriptInit if filterscript, if in gamemode will be OnGameModeInit



public OnFilterScriptInit() // If filterscript
{
gBotID[0] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_1_NICKNAME, BOT_1_REALNAME, BOT_1_USERNAME);
IRC_SetIntData(gBotID[0], E_IRC_CONNECT_DELAY, 20);
return 1;
}
This is will connect the IRC Bots to the network,channel we defined above


gBotID[0] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_1_NICKNAME, BOT_1_REALNAME, BOT_1_USERNAME);


Now this is the delay,  It will connect the several bots and giving your server time to load all the codes of the IRC Script, 20 is the seconds for Ex.


IRC_SetIntData(gBotID[0], E_IRC_CONNECT_DELAY, [color=red]20[/color]);



Okay, here the OnPlayerConnect partition, when player connected it'll send message (%s has connected to the server).


public OnPlayerConnect(playerid)
{
new joinMsg[128], name[MAX_PLAYER_NAME]; //here we are creating a local variable for getting the players name
GetPlayerName(playerid, name, sizeof(name));
format(joinMsg, sizeof(joinMsg), "02[%d] 03*** %s has connected to the server.", playerid, name);
IRC_GroupSay(gGroupID, IRC_CHANNEL, joinMsg); //joing the player to the channel that we defined!
return 1;
}


Here the OnPlayerText part, it'll echo when player talk or send messages to the main chat


public OnPlayerText(playerid, text[])
{
new name[MAX_PLAYER_NAME], ircMsg[256]; Again creating a local Variable for name!
GetPlayerName(playerid, name, sizeof(name)); //getting the players name.
format(ircMsg, sizeof(ircMsg), "02[%d] 07%s: %s", playerid, name, text); //creating the message
IRC_GroupSay(gGroupID, IRC_CHANNEL, ircMsg);
//rest of your OnPlayerText Here!
return 1;
}
Some Callbacks which will be important for the IRC Script

These callbacks is already in the IRC include.



public IRC_OnConnect(botid, ip[], port)
{
printf("*** IRC_OnConnect: Bot ID %d connected to %s:%d", botid, ip, port);
return 1;
}

!msg command

Ok, I made many commands in my own IRC System which it's Link is mentioned above, I made their many commands, I'll show example of how to make 1 of them like (!msg to speak from IRC to game)


IRCCMD:msg(botid, channel[], user[], host[], params[]) //making the command, in this case "say"
{
// It's for Voice only (+v) who can use the !msg command (voice people by /voice <nickname>)
if (IRC_IsVoice(botid, channel, user))
{
// This for checking if the guest/voiced person typed a text or just typed "!msg"
if (!isnull(params))
{
new msg[128]; 
format(msg, sizeof(msg), "02*** %s on IRC: %s", user, params);
IRC_GroupSay(gGroupID, channel, msg);
format(msg, sizeof(msg), "*** %s on IRC: %s", user, params);
SendClientMessageToAll(0x0000FFFF, msg);//you can change colors here
}
}
return 1;
}

More tutorials is coming soon, I just made small & short one to help people, any question reply down or PM me.
 - Thanks to Post4VPS & Host4Fun for the amazing VPS 1 -


Messages In This Thread
How to add IRC System in sa-mp gamemode! - by Ultraz - 09-23-2017, 11:05 PM

Possibly Related Threads…
Thread
Author
Replies
Views
Last Post

person_pin_circle Users browsing this thread: 1 Guest(s)
Sponsors: VirMach - Host4Fun - CubeData - Evolution-Host - HostDare - Hyper Expert - Shadow Hosting - Bladenode - Hostlease - RackNerd - ReadyDedis - Limitless Hosting