arrow_upward

Pages (2):
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 -
#2
(09-24-2017, 11:36 AM)arsalahmed786 Wrote: @Ultraz WOW Great tutorial. Actually i'm not SAMP player. Hope it's workable for them whom want it. There a lots of people who want SAMP related tutorials.

But mostly members want Tutorial about VPSs.
I will try to make tutorial about VPSs soon when I get free time, thanks for feedback bruh.

(09-24-2017, 12:17 PM)AmirGT Wrote: Nice work Ultraz and keep it up but can I make this bot admin and control it while I'm not in game?
Yes you can from mobile or laptop or computer, you can use mIRC for PC and AndroIRC or IRC Cloud on mobile then connect to your IRC Network and channel and use /op "Bot Nickname" it'll get Operator position in channel
#3
@Ultraz Great Tutorial for newbies, keep it up 
- waiting more tutorials from you... Big Grin

Edit: gGroupID variable isn't assigned to any Group on OnGameModeInit callback
missing code:
public OnGameModeInit()
{
   gGroupID = IRC_CreateGroup();
   return 1;
}
Thanks to @Post4VPS & @Hostdare for Providing their VPS Hosting Services: VPS 12
#4
(09-26-2017, 05:25 PM)Zorono Wrote: @Ultraz Great Tutorial for newbies, keep it up 
- waiting more tutorials from you... Big Grin

Edit: gGroupID variable isn't assigned to any Group on OnGameModeInit callback
missing code:
public OnGameModeInit()
{
   gGroupID = IRC_CreateGroup();
   return 1;
}
gGroupID variable is not assigned to anyone its just a name / text anyone can change it to his own defines, as well I typed above that it is my variable on UltraZ IRC system ( which I have mentioned above ) and Noaph ( other filterscript creator ) used same so it would be easy for newbies which will just copy my commands without knowing how to change variables.
Ultraz.
 - Thanks to Post4VPS & Host4Fun for the amazing VPS 1 -
#5
thats very good tutorial! i will make this irc bots when i will have time... i own a server in samp and its very usefull for me
Thank you Post4vps and BladeNode for vps 6!!!
#6
(10-03-2017, 05:59 AM)OldMeister Wrote: thats very good tutorial! i will make this irc bots when i will have time... i own a server in samp and its very usefull for me

Good luck dude any help you want pm me here on forum and I will surely help you :')
 - Thanks to Post4VPS & Host4Fun for the amazing VPS 1 -
#7
@Ultraz
Iam having some problems as i type irc.tl and it doesn't connect, do you have any solution for this problem?
#8
(10-10-2017, 02:40 PM)youssefbasha Wrote: @Ultraz
Iam having some problems as i type irc.tl and it doesn't connect, do you have any solution for this problem?

IRC.TL changed the server hostname to pool.irc.tl not irc.tl then it will connect ✋
 - Thanks to Post4VPS & Host4Fun for the amazing VPS 1 -
#9
(10-10-2017, 08:44 PM)Ultraz Wrote: IRC.TL changed the server hostname to pool.irc.tl not irc.tl then it will connect ✋

Oh, okay thx!
It worked with me now but can you add IRCCMD:oban?
I need it to much so if you don't mind to add it / send it on pm.
#10
(10-11-2017, 04:32 AM)youssefbasha Wrote: Oh, okay thx!
It worked with me now but can you add IRCCMD:oban?
I need it to much so if you don't mind to add it / send it on pm.

Ok i will surely add it here on this tutorial thread, but if you really need it you will find it on my IRC System on sa-mp forums (link above in the thread).
 - Thanks to Post4VPS & Host4Fun for the amazing VPS 1 -
Pages (2):


Possibly Related Threads…
Thread
Author
Replies
Views
Last Post

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