06.03.2013, 11:05
(
Последний раз редактировалось mgd; 08.03.2013 в 07:10.
)
Introduction
Hey Guys , after 1-2 days of working on that irc script
finally i finished it , and i tested it and it worked 100%.
Commands
simple , Do !cmds when you on the irc script on your channel and the bot gonna message you all the commands that you can use.
Credits
mgd - Me
Incognito for the irc plugin
Deron_Green for the !credits and !cmds cmd
Downloads
Pastebin
http://pastebin.com/8Dd25xWg
mediafire
http://www.mediafire.com/?iyqi2lf36d3bzt6
Enjoy
Hey Guys , after 1-2 days of working on that irc script
finally i finished it , and i tested it and it worked 100%.
Commands
simple , Do !cmds when you on the irc script on your channel and the bot gonna message you all the commands that you can use.
pawn Код:
#include <a_samp>
#include <irc>
#include <sscanf2>
#define BOT_1_NICKNAME "youbotname"
#define BOT_1_REALNAME "SA-MP Bot"
#define BOT_1_USERNAME "bot"
#define BOT_2_NICKNAME "youbotname"
#define BOT_2_REALNAME "SA-MP Bot"
#define BOT_2_USERNAME "bot"
#define IRC_SERVER "your server"
#define IRC_PORT (6667)
#define IRC_CHANNEL "#yourchannel"
#define MAX_BOTS (2)
#define PLUGIN_VERSION "1.4.3"
new botIDs[MAX_BOTS], groupID;
public OnFilterScriptInit()
{
botIDs[0] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_1_NICKNAME, BOT_1_REALNAME, BOT_1_USERNAME);
IRC_SetIntData(botIDs[0], E_IRC_CONNECT_DELAY, 20);
botIDs[1] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_2_NICKNAME, BOT_2_REALNAME, BOT_2_USERNAME);
IRC_SetIntData(botIDs[1], E_IRC_CONNECT_DELAY, 30);
groupID = IRC_CreateGroup();
}
public OnFilterScriptExit()
{
IRC_Quit(botIDs[0], "Filterscript exiting");
IRC_Quit(botIDs[1], "Filterscript exiting");
IRC_DestroyGroup(groupID);
}
public OnPlayerConnect(playerid)
{
new joinMsg[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(joinMsg, sizeof(joinMsg), "02[%d] 03*** %s has joined the server.", playerid, name);
IRC_GroupSay(groupID, IRC_CHANNEL, joinMsg);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new leaveMsg[128], name[MAX_PLAYER_NAME], reasonMsg[8];
switch(reason)
{
case 0: reasonMsg = "Timeout";
case 1: reasonMsg = "Leaving";
case 2: reasonMsg = "Kicked";
}
GetPlayerName(playerid, name, sizeof(name));
format(leaveMsg, sizeof(leaveMsg), "02[%d] 03*** %s has left the server. (%s)", playerid, name, reasonMsg);
IRC_GroupSay(groupID, IRC_CHANNEL, leaveMsg);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
new msg[128], killerName[MAX_PLAYER_NAME], reasonMsg[32], playerName[MAX_PLAYER_NAME];
GetPlayerName(killerid, killerName, sizeof(killerName));
GetPlayerName(playerid, playerName, sizeof(playerName));
if (killerid != INVALID_PLAYER_ID)
{
switch (reason)
{
case 0: reasonMsg = "Unarmed";
case 1: reasonMsg = "Brass Knuckles";
case 2: reasonMsg = "Golf Club";
case 3: reasonMsg = "Night Stick";
case 4: reasonMsg = "Knife";
case 5: reasonMsg = "Baseball Bat";
case 6: reasonMsg = "Shovel";
case 7: reasonMsg = "Pool Cue";
case 8: reasonMsg = "Katana";
case 9: reasonMsg = "Chainsaw";
case 10: reasonMsg = "Dildo";
case 11: reasonMsg = "Dildo";
case 12: reasonMsg = "Vibrator";
case 13: reasonMsg = "Vibrator";
case 14: reasonMsg = "Flowers";
case 15: reasonMsg = "Cane";
case 22: reasonMsg = "Pistol";
case 23: reasonMsg = "Silenced Pistol";
case 24: reasonMsg = "Desert Eagle";
case 25: reasonMsg = "Shotgun";
case 26: reasonMsg = "Sawn-off Shotgun";
case 27: reasonMsg = "Combat Shotgun";
case 28: reasonMsg = "MAC-10";
case 29: reasonMsg = "MP5";
case 30: reasonMsg = "AK-47";
case 31: reasonMsg = "M4";
case 32: reasonMsg = "TEC-9";
case 33: reasonMsg = "Country Rifle";
case 34: reasonMsg = "Sniper Rifle";
case 37: reasonMsg = "Fire";
case 38: reasonMsg = "Minigun";
case 41: reasonMsg = "Spray Can";
case 42: reasonMsg = "Fire Extinguisher";
case 49: reasonMsg = "Vehicle Collision";
case 50: reasonMsg = "Vehicle Collision";
case 51: reasonMsg = "Explosion";
default: reasonMsg = "Unknown";
}
format(msg, sizeof(msg), "04*** %s killed %s. (%s)", killerName, playerName, reasonMsg);
}
else
{
switch (reason)
{
case 53: format(msg, sizeof(msg), "04*** %s died. (Drowned)", playerName);
case 54: format(msg, sizeof(msg), "04*** %s died. (Collision)", playerName);
default: format(msg, sizeof(msg), "04*** %s died.", playerName);
}
}
IRC_GroupSay(groupID, IRC_CHANNEL, msg);
return 1;
}
public OnPlayerText(playerid, text[])
{
new name[MAX_PLAYER_NAME], ircMsg[256];
GetPlayerName(playerid, name, sizeof(name));
format(ircMsg, sizeof(ircMsg), "02[%d] 07%s: %s", playerid, name, text);
IRC_GroupSay(groupID, IRC_CHANNEL, ircMsg);
return 1;
}
public IRC_OnConnect(botid, ip[], port)
{
printf("*** IRC_OnConnect: Bot ID %d connected to %s:%d", botid, ip, port);
IRC_JoinChannel(botid, IRC_CHANNEL);
IRC_AddToGroup(groupID, botid);
return 1;
}
public IRC_OnDisconnect(botid, ip[], port, reason[])
{
printf("*** IRC_OnDisconnect: Bot ID %d disconnected from %s:%d (%s)", botid, ip, port, reason);
IRC_RemoveFromGroup(groupID, botid);
return 1;
}
public IRC_OnConnectAttempt(botid, ip[], port)
{
printf("*** IRC_OnConnectAttempt: Bot ID %d attempting to connect to %s:%d...", botid, ip, port);
return 1;
}
public IRC_OnConnectAttemptFail(botid, ip[], port, reason[])
{
printf("*** IRC_OnConnectAttemptFail: Bot ID %d failed to connect to %s:%d (%s)", botid, ip, port, reason);
return 1;
}
public IRC_OnJoinChannel(botid, channel[])
{
printf("*** IRC_OnJoinChannel: Bot ID %d joined channel %s", botid, channel);
return 1;
}
public IRC_OnLeaveChannel(botid, channel[], message[])
{
printf("*** IRC_OnLeaveChannel: Bot ID %d left channel %s (%s)", botid, channel, message);
return 1;
}
public IRC_OnInvitedToChannel(botid, channel[], invitinguser[], invitinghost[])
{
printf("*** IRC_OnInvitedToChannel: Bot ID %d invited to channel %s by %s (%s)", botid, channel, invitinguser, invitinghost);
IRC_JoinChannel(botid, channel);
return 1;
}
public IRC_OnKickedFromChannel(botid, channel[], oppeduser[], oppedhost[], message[])
{
printf("*** IRC_OnKickedFromChannel: Bot ID %d kicked by %s (%s) from channel %s (%s)", botid, oppeduser, oppedhost, channel, message);
IRC_JoinChannel(botid, channel);
return 1;
}
public IRC_OnUserDisconnect(botid, user[], host[], message[])
{
printf("*** IRC_OnUserDisconnect (Bot ID %d): User %s (%s) disconnected (%s)", botid, user, host, message);
return 1;
}
public IRC_OnUserJoinChannel(botid, channel[], user[], host[])
{
printf("*** IRC_OnUserJoinChannel (Bot ID %d): User %s (%s) joined channel %s", botid, user, host, channel);
return 1;
}
public IRC_OnUserLeaveChannel(botid, channel[], user[], host[], message[])
{
printf("*** IRC_OnUserLeaveChannel (Bot ID %d): User %s (%s) left channel %s (%s)", botid, user, host, channel, message);
return 1;
}
public IRC_OnUserKickedFromChannel(botid, channel[], kickeduser[], oppeduser[], oppedhost[], message[])
{
printf("*** IRC_OnUserKickedFromChannel (Bot ID %d): User %s kicked by %s (%s) from channel %s (%s)", botid, kickeduser, oppeduser, oppedhost, channel, message);
}
public IRC_OnUserNickChange(botid, oldnick[], newnick[], host[])
{
printf("*** IRC_OnUserNickChange (Bot ID %d): User %s (%s) changed his/her nick to %s", botid, oldnick, host, newnick);
return 1;
}
public IRC_OnUserSetChannelMode(botid, channel[], user[], host[], mode[])
{
printf("*** IRC_OnUserSetChannelMode (Bot ID %d): User %s (%s) on %s set mode: %s", botid, user, host, channel, mode);
return 1;
}
public IRC_OnUserSetChannelTopic(botid, channel[], user[], host[], topic[])
{
printf("*** IRC_OnUserSetChannelTopic (Bot ID %d): User %s (%s) on %s set topic: %s", botid, user, host, channel, topic);
return 1;
}
public IRC_OnUserSay(botid, recipient[], user[], host[], message[])
{
printf("*** IRC_OnUserSay (Bot ID %d): User %s (%s) sent message to %s: %s", botid, user, host, recipient, message);
if (!strcmp(recipient, BOT_1_NICKNAME))
{
IRC_Say(botid, user, "You sent me a PM!");
}
return 1;
}
public IRC_OnUserNotice(botid, recipient[], user[], host[], message[])
{
printf("*** IRC_OnUserNotice (Bot ID %d): User %s (%s) sent notice to %s: %s", botid, user, host, recipient, message);
if (!strcmp(recipient, BOT_2_NICKNAME))
{
IRC_Notice(botid, user, "You sent me a notice!");
}
return 1;
}
public IRC_OnUserRequestCTCP(botid, user[], host[], message[])
{
printf("*** IRC_OnUserRequestCTCP (Bot ID %d): User %s (%s) sent CTCP request: %s", botid, user, host, message);
if (!strcmp(message, "VERSION"))
{
IRC_ReplyCTCP(botid, user, "VERSION SA-MP IRC Plugin v" #PLUGIN_VERSION "");
}
return 1;
}
public IRC_OnUserReplyCTCP(botid, user[], host[], message[])
{
printf("*** IRC_OnUserReplyCTCP (Bot ID %d): User %s (%s) sent CTCP reply: %s", botid, user, host, message);
return 1;
}
public IRC_OnReceiveRaw(botid, message[])
{
new File:file;
if (!fexist("irc_log.txt"))
{
file = fopen("irc_log.txt", io_write);
}
else
{
file = fopen("irc_log.txt", io_append);
}
if (file)
{
fwrite(file, message);
fwrite(file, "\r\n");
fclose(file);
}
return 1;
}
IRCCMD:say(botid, channel[], user[], host[], params[])
{
if (IRC_IsVoice(botid, channel, user))
{
if (!isnull(params))
{
new msg[128];
format(msg, sizeof(msg), "02*** %s on IRC: %s", user, params);
IRC_GroupSay(groupID, channel, msg);
format(msg, sizeof(msg), "*** %s on IRC: %s", user, params);
SendClientMessageToAll(0x0000FFFF, msg);
}
}
return 1;
}
IRCCMD:kick(botid, channel[], user[], host[], params[])
{
if (IRC_IsHalfop(botid, channel, user))
{
new playerid, reason[64];
if (sscanf(params, "dS(No reason)[64]", playerid, reason))
{
return 1;
}
if (IsPlayerConnected(playerid))
{
new msg[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(msg, sizeof(msg), "02*** %s has been kicked by Administrator on IRC. (%s)", name, user, reason);
IRC_GroupSay(groupID, channel, msg);
format(msg, sizeof(msg), "*** %s has been kicked by Administrator on IRC. (%s)", name, user, reason);
SendClientMessageToAll(0x0000FFFF, msg);
Kick(playerid);
}
}
return 1;
}
IRCCMD:ban(botid, channel[], user[], host[], params[])
{
if (IRC_IsOp(botid, channel, user))
{
new playerid, reason[64];
if (sscanf(params, "dS(No reason)[64]", playerid, reason))
{
return 1;
}
if (IsPlayerConnected(playerid))
{
new msg[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(msg, sizeof(msg), "02*** %s has been banned by %s on IRC. (%s)", name, user, reason);
IRC_GroupSay(groupID, channel, msg);
format(msg, sizeof(msg), "*** %s has been banned by %s on IRC. (%s)", name, user, reason);
SendClientMessageToAll(0x0000FFFF, msg);
BanEx(playerid, reason);
}
}
return 1;
}
IRCCMD:rcon(botid, channel[], user[], host[], params[])
{
if (IRC_IsOp(botid, channel, user))
{
if (!isnull(params))
{
if (strcmp(params, "exit", true) != 0 && strfind(params, "loadfs irc", true) == -1)
{
new msg[128];
format(msg, sizeof(msg), "RCON command %s has been executed.", params);
IRC_GroupSay(groupID, channel, msg);
SendRconCommand(params);
}
}
}
return 1;
}
IRCCMD:respawncars(botid, channel[], user[], host[], params[])
{
new string1[128], string2[128];
if (IRC_IsVoice(botid, channel, user))
{
for(new i = 1; i <= MAX_VEHICLES; i++)
{
SetVehicleToRespawn(i);
}
format(string1, 128, "Administrator %s has respawned all vehicles", user);
format(string2, 128, "Administrator %s has respawned all vehicles", user);
IRC_GroupSay(groupID, channel, string1);
SendClientMessageToAll(0x00E800C8, string2);
}
return 1;
}
IRCCMD:getname(botid, channel[], user[], host[], params[])
{
new playerid;
//Playerid
if (sscanf(params, "d", playerid))
{
return 1;
}
if(IsPlayerConnected(playerid))
{
new msg[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(msg, sizeof(msg), "*** The player's name is %s", pname, user);
IRC_GroupSay(groupID, channel, msg);
}
return 1;
}
IRCCMD:giveallcash(botid, channel[], user[], host[], params[])
{
new value;
new msg1[128];
new msg2[128];
if(sscanf(params, "d", value) != 0)
{
return 1;
}
if (IRC_IsVoice(botid, channel, user))
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
GivePlayerMoney(i, value);
format(msg1, sizeof(msg1), "Administrator %s on irc has given all players some cash!", user);
IRC_GroupSay(groupID, channel, msg1);
format(msg2, sizeof(msg2), "Administrator %s on irc has given all players some cash!", user);
SendClientMessageToAll(0x00E600C8, msg2);
}
}
}
return 1;
}
IRCCMD:resetcash(botid, channel[], user[], host[], params[])
{
new playerid, reason[64];
//Playerid
if (sscanf(params, "dS(No reason.)[64]", playerid, reason))
{
return 1;
}
if (IRC_IsHalfop(botid, channel, user))
{
if(IsPlayerConnected(playerid))
{
new msg[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(msg, sizeof(msg), "Admin Reseted Cash %s on IRC for reason: %s", pname, user, reason);
IRC_GroupSay(groupID, channel, msg);
format(msg, sizeof(msg), "Admin Reseted Cash %s on IRC for reason: %s", pname, user, reason);
SendClientMessageToAll(0xFF0000C8, msg);
ResetPlayerMoney(playerid);
}
}
return 1;
}
IRCCMD:explode(botid, channel[], user[], host[], params[])
{
new playerid, reason[64];
new player1;
//Playerid
if (sscanf(params, "dS(No reason.)[64]", playerid, reason))
{
return 1;
}
if (IRC_IsHalfop(botid, channel, user))
{
if(IsPlayerConnected(playerid))
{
new msg[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(msg, sizeof(msg), "%s has been exploded by Administrator on IRC", pname, user, reason);
IRC_GroupSay(groupID, channel, msg);
format(msg, sizeof(msg), "%s has been exploded by Administrator on IRC", pname, user, reason);
SendClientMessageToAll(0xFF0000C8, msg);
new Float:x, Float:y, Float:z;
GetPlayerPos(player1,x,y,z);
CreateExplosion(x, y, z, 0, 10.0);
}
}
return 1;
}
IRCCMD:unfreeze(botid, channel[], user[], host[], params[])
{
new playerid, reason[64];
//Playerid
if (sscanf(params, "dS(No reason.)[64]", playerid, reason))
{
return 1;
}
if (IRC_IsHalfop(botid, channel, user))
{
if(IsPlayerConnected(playerid))
{
new msg[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(msg, sizeof(msg), "%s has been unfrozen by Admin on IRC", pname, user, reason);
IRC_GroupSay(groupID, channel, msg);
format(msg, sizeof(msg), "%s has been unfrozen by Admin on IRC", pname, user, reason);
SendClientMessageToAll(0x00E600C8, msg);
TogglePlayerControllable(playerid, 1);
}
}
return 1;
}
IRCCMD:freeze(botid, channel[], user[], host[], params[])
{
new playerid, reason[64];
if (sscanf(params, "dS(No reason.)[64]", playerid, reason))
{
return 1;
}
if (IRC_IsHalfop(botid, channel, user))
{
if(IsPlayerConnected(playerid))
{
new msg[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(msg, sizeof(msg), "%s has been frozen by Admin on IRC", pname, user, reason);
IRC_GroupSay(groupID, channel, msg);
format(msg, sizeof(msg), "%s has been frozen by Admin on IRC", pname, user, reason);
SendClientMessageToAll(0xFF0000C8, msg);
TogglePlayerControllable(playerid, 0);
}
}
return 1;
}
IRCCMD:warn(botid, channel[], user[], host[], params[])
{
new playerid, reason[64];
if (sscanf(params, "dS(No reason.)[64]", playerid, reason))
{
return 1;
}
if (IRC_IsVoice(botid, channel, user))
{
if(IsPlayerConnected(playerid))
{
new msg[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(msg, sizeof(msg), "%s has been warned by Administrator on IRC", pname, user, reason);
IRC_GroupSay(groupID, channel, msg);
format(msg, sizeof(msg), "%s has been warned by Administrator on IRC", pname, user, reason);
SendClientMessageToAll(0xFFFF00C8, msg);
}
}
return 1;
}
IRCCMD:players( botid, channel[], user[], host[], params[] )
{
new tempstr[128], string[200], count, name[24];
for( new i ,slots = GetMaxPlayers(); i < slots; i++ )
{
if(IsPlayerConnected(i))
{
count++;
GetPlayerName(i, name, sizeof(name));
format(tempstr, sizeof(tempstr), "%s , %s", tempstr, name);
}
}
if(count)
{
format(string, sizeof(string), "Connected Players[%d/%d]:- %s", count, GetMaxPlayers(), tempstr);
IRC_Say(botid, channel, string);
} else IRC_Say(botid, channel, "No players are online.");
return 1;
}
IRCCMD:clearchat(conn, channel[], user[], message[])
{
if(IRC_IsHalfop(conn, channel, user) == 0) return IRC_Say(conn, channel, "Invalid Level");
{
for( new i = 0; i <= 100; i ++ ) SendClientMessageToAll(0xFFFFFF, "" );
SendClientMessageToAll(0xFFFFFF, "An Admin As Cleared The Chat");
}
#pragma unused message
return 1;
}
IRCCMD:cmds(botid, channel[], user[], host[], params[])
{
if(!strcmp(channel, channel, true))
{
IRC_Say(botid, user, "04 [IRC Commands] ");
IRC_Say(groupID, user, "| User: !players !credits !say ");
{
if(IRC_IsHalfop(botid, channel, user))
{
IRC_Say(groupID, user, "| Halfops: !slap !ban !kick !warn !freeze !unfreeze ");
}
if(IRC_IsOp(botid, channel, user))
{
IRC_Say(groupID, user, "| Operators: !explode !slap !ban !kick !clearchat !warn !freeze !unfreeze ");
}
if(IRC_IsAdmin(botid, channel, user))
{
IRC_Say(groupID, user, "| Administrators: !say !slap !ban !kick !clearchat !warn !freeze !unfreeze !resetcash ");
}
if(IRC_IsOwner(botid, channel, user))
{
IRC_Say(groupID, user, "| Owner: All Levels and cmds , !say !slap !ban !kick !clearchat !warn !freeze !unfreeze !resetcash !rcon ");
}
}
}
return 1;
}
IRCCMD:credits(botid, channel[], user[], host[], params[])
{
IRC_Notice(botid, user, "04___________________________________");
IRC_Notice(botid, user, "04 IRC script ");
IRC_Notice(botid, user, "04 Made by Mr_King Or Mgd ");
IRC_Notice(botid, user, "04 Thanks For Choose This Irc Script! ");
IRC_Notice(botid, user, "04___________________________________");
return 1;
}
//do not remove the credits please.
mgd - Me
Incognito for the irc plugin
Deron_Green for the !credits and !cmds cmd
Downloads
Pastebin
http://pastebin.com/8Dd25xWg
mediafire
http://www.mediafire.com/?iyqi2lf36d3bzt6
Enjoy