pawn Код:
//==============================================================================
// GarIRC v1.1 by [03]Garsino
//==============================================================================
// - Credits to Zeex for ZCMD.
// - Credits to Incognito for his IRC plugin.
// - Credits to ****** for sscanf 2.0 and foreach.
//==============================================================================
// Changelog v1.1
//==============================================================================
// [Fixed] Fixed !botidentify.
// [Script] Improved !botidentify.
// [Script] Removed format() part from !botregister, seeing as it was unneccesary.
// [Script] Improved !restart.
// [Script] Improved !botjoin.
// [Script] Improved !ikick.
// [Script] Improved !iban.
// [Script] Improved IRC_OnConnectAttemptFail.
// [Script] Improved IRC_OnConnect.
// [Added] Added a PIP_FIX define. Set this to true if you're having problems with GetPlayerIpEx returning an empty IP.
// [Added] Added a PNICK_FIX define. Set this to true if you're having problems with pNick returning an empty name.
// [Added] Added a COMMAND_TO_CHAT define. Set this to true if you want to disable the whole chat-to-talk feature and use !say instead.
// [Added] Added a SAY_ECHO_CHANNEL_ONLY define. Set this to true if COMMAND_TO_CHAT is set to true and you only want !say accessible in the .echo and .aecho channels.
// [Added] Added !sendraw command for sending a raw message to the IRC server using a specific bot.
// [Added] Added !sendrawall command for sending a raw message to the IRC serverusing all IRC bots.
// [Added] Added a !say command for use by admins (or for everyone if COMMAND_TO_CHAT is set to true or by voice (+v) -> if VOICE_TO_CHAT is set to true).
//==============================================================================
// Includes
//==============================================================================
#include <irc> // Credits to Incognito
#include <a_samp>
#include <a_npc>
#include <sscanf2> // Credits to ******
#include <foreach> // Credits to ******
#include <zcmd> // Credits to Zeex
//==============================================================================
// Configuration
//==============================================================================
#define COMMAND_TO_CHAT false // true: You will need to use !say to chat to the server. | false: You can just talk in the echo channel without using !say to chat to the server.
#define SAY_ECHO_CHANNEL_ONLY true // true: The !say command will only be available in the .echo and .aecho channels. | false: The !say commands will be available in all the channels specified in this script.
#define PNICK_FIX false // true: GetPlayerName will be called everytime pNick is used (inefficient, but should work if you're having problems with pNick returning blank names). | false: The script will store the player name to a variable upon connect and return that one when pNick is called.
#define PIP_FIX false // true: GetPlayerIp will be called everytime GetPlayerIpEx is used (inefficient, but should work if you're having problems with GetPlayerIpEx returning blank IPs). | false: The script will store the player IP to a variable upon connect and return that one when GetPlayerIpEx is called.
#define VOICE_TO_CHAT false // true: The players will need voice on IRC to send their messages to in-game. | false: The players do not need voice on IRC in order to send their messages to in-game.
#define IRC_SERVER "irc.mibbit.net" // The IRC server you want to connect to (SA:MP's "official" one (ran by betatesters) is irc.focogaming.com).
#define IRC_PORT 6667 // The IRC port you want to connect to (Standard port is 6667 (or 8067)).
#define IRC_CHANNEL "#rbirc2" // The main channel (the bots will only idle in here).
#define IRC_ECHO_CHANNEL "#changeme.echo" // The echo channel (the bots will echo chat messages and so on into here).
#define IRC_AECHO_CHANNEL "#changeme.aecho" // The admin echo channel (the bots will echo admin stuff into here like IPs and so on).
#define MAX_BOTS 3 // How many bots should the script try to connect? (Remember: Most IRC servers have a connection limit of 5. Connecting more than that will lead to a ban from the server).
#define BOT_NICKNAME "GarIRC" // The username the bots will use followed by 2 square brackets with numbers in it (f.ex. GarIRC[1], GarIRC[2], GarIRC[3], etc.).
#define BOT_REALNAME "GarIRC" // The "realname" of the IRC bots (will only be visible in a /whois).
#define BOT_USERNAME "GarIRC" // The name that will be infront of the hostname (username@hostname).
#define BOT_PASSWORD "changeme" // The password that the IRC bots will use for registering/logging in.
#define BOT_EMAIL "dfgvb250@gmail.com" // The e-mail that the IRC bots will use upon registration (and if you ever forget the password for the IRC bots, lol).
#define IRC_CONNECT_DELAY 5 // Time to wait between connecting each bot (in seconds).
#define IRC_CONNECT_ATTEMPTS 5 // How many attempts it will try to connect to the IRC server.
#define IRC_REGISTER_DELAY 30000 // Time to wait before registering each bot (in ms).
//==============================================================================
// Colours
//==============================================================================
#define COLOUR_IRC 0x0066CCFF
#define COLOUR_INFO 0x00FFFFFF
#define COLOUR_SYSTEM 0xFF0000FF
#define COLOUR_ADMIN 0xCC00CCFF
#define COLOUR_PM 0xFFFF2AFF
//==============================================================================
// Variables/Macros
//==============================================================================
#undef MAX_PLAYER_NAME
#define MAX_PLAYER_NAME 24
new gGroupID, gBotID[MAX_BOTS char], CMDSString[1048], FALSE = false, pName[MAX_PLAYERS][MAX_PLAYER_NAME], PlayerIP[MAX_PLAYERS][16];
#define IRC_GroupSayEx(%0,%1,%2,%3) do{CMDSString = ""; format(CMDSString, sizeof(CMDSString), %2, %3); IRC_GroupSay(%0, %1, CMDSString);}while(FALSE)
#define IRC_GroupNoticeEx(%0,%1,%2,%3) do{CMDSString = ""; format(CMDSString, sizeof(CMDSString), %2, %3); IRC_GroupNotice(%0, %1, CMDSString);}while(FALSE)
#define SendMSG(%0,%1,%2,%3) do{CMDSString = ""; format(CMDSString, sizeof(CMDSString), %2, %3); SendClientMessage(%0, %1, CMDSString);}while(FALSE)
#define SendMSGToAll(%0,%1,%2) do{CMDSString = ""; format(CMDSString, sizeof(CMDSString), %1, %2); SendClientMessageToAll(%0, CMDSString);}while(FALSE)
//==============================================================================
// IRC Callbacks
//==============================================================================
forward OnFilterScriptInit;
public OnFilterScriptInit()
{
new string[50];
print(">> GarIRC v1.1: Attempting to connect "#MAX_BOTS" IRC bots...");
for(new bot = 1; bot <= MAX_BOTS; bot++)
{
format(string, sizeof(string), "%s[%d]", BOT_NICKNAME, bot);
gBotID{(bot-1)} = IRC_Connect(IRC_SERVER, IRC_PORT, string, BOT_REALNAME, BOT_USERNAME);
IRC_SetIntData(gBotID{(bot-1)}, E_IRC_CONNECT_DELAY, (IRC_CONNECT_DELAY * bot));
IRC_SetIntData(gBotID{(bot-1)}, E_IRC_CONNECT_ATTEMPTS, IRC_CONNECT_ATTEMPTS);
}
gGroupID = IRC_CreateGroup();
print(">> GarIRC v1.1: Connection initalized...");
return 1;
}
public OnFilterScriptExit()
{
print(">> GarIRC v1.1: Disconnecting IRC bots...");
for(new bot = 0; bot < MAX_BOTS; bot++)
{
IRC_Quit(gBotID{bot}, "Using GarIRC v1.1 by [03]Garsino");
}
IRC_DestroyGroup(gGroupID);
print(">> GarIRC v1.1: IRC bots disconnected...");
}
public OnPlayerConnect(playerid)
{
GetPlayerName(playerid, pName[playerid], MAX_PLAYER_NAME), GetPlayerIp(playerid, PlayerIP[playerid], 16);
IRC_GroupSayEx(gGroupID, IRC_ECHO_CHANNEL, "7[connect] 3%s (%d) has joined the server.", pName[playerid], playerid);
IRC_GroupSayEx(gGroupID, IRC_AECHO_CHANNEL, "7[connect] 3%s (%d) has joined the server (IP: %s).", pName[playerid], playerid, PlayerIP[playerid]);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
switch(reason)
{
case 0:
{
IRC_GroupSayEx(gGroupID, IRC_ECHO_CHANNEL, "7[disconnect] 3%s (%d) has left the server (Timeout).", pNick(playerid), playerid);
IRC_GroupSayEx(gGroupID, IRC_AECHO_CHANNEL, "7[disconnect] 3%s (%d) has left the server (Timeout) - (IP: %s).", pNick(playerid), playerid, GetPlayerIpEx(playerid));
}
case 1:
{
IRC_GroupSayEx(gGroupID, IRC_ECHO_CHANNEL, "7[disconnect] 3%s (%d) has left the server (Quit).", pNick(playerid), playerid);
IRC_GroupSayEx(gGroupID, IRC_AECHO_CHANNEL, "7[disconnect] 3%s (%d) has left the server (Quit) - (IP: %s).", pNick(playerid), playerid, GetPlayerIpEx(playerid));
}
case 2:
{
IRC_GroupSayEx(gGroupID, IRC_ECHO_CHANNEL, "7[disconnect] 3%s (%d) has left the server (Kicked/Banned).", pNick(playerid), playerid);
IRC_GroupSayEx(gGroupID, IRC_AECHO_CHANNEL, "7[disconnect] 3%s (%d) has left the server (Kicked/Banned) - (IP: %s).", pNick(playerid), playerid, GetPlayerIpEx(playerid));
}
}
return 1;
}
public OnPlayerSpawn(playerid)
{
IRC_GroupSayEx(gGroupID, IRC_AECHO_CHANNEL, "7[spawn] 3%s (%d) has spawned.", pNick(playerid), playerid);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid == INVALID_PLAYER_ID)
{
IRC_GroupSayEx(gGroupID, IRC_ECHO_CHANNEL, "7[death] 3%s (%d) died (%s).", pNick(playerid), playerid, GetDeathReason(killerid, reason));
}
else IRC_GroupSayEx(gGroupID, IRC_ECHO_CHANNEL, "7[death] 3%s (%d) was killed by %s (%d) (%s).", pNick(playerid), playerid, pNick(killerid), killerid, GetDeathReason(killerid, reason));
return 1;
}
public OnPlayerText(playerid, text[])
{
IRC_GroupSayEx(gGroupID, IRC_ECHO_CHANNEL, "7[chat] 3%s (%d): %s", pNick(playerid), playerid, text);
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
if(!success)
{
foreach(Character, i)
{
if(IsPlayerAdmin(i)) continue;
if(!strcmp(GetPlayerIpEx(i), ip)) continue;
IRC_GroupSayEx(gGroupID, IRC_AECHO_CHANNEL, "7[rcon login] 3%s (%d) attempted to login to RCON.", pNick(i), i);
return 1;
}
}
return 1;
}
//==============================================================================
// IRC Callbacks
//==============================================================================
forward IRC_RegisterDelay(botid);
public IRC_RegisterDelay(botid)
{
IRC_SendRaw(botid, "ns register "BOT_PASSWORD" "BOT_EMAIL"");
IRC_GroupSayEx(gGroupID, IRC_AECHO_CHANNEL, "7[bot register] 3attempting to register bot ID %d with the password \""BOT_PASSWORD"\" and the e-mail \""BOT_EMAIL"\".", botid);
return 1;
}
public IRC_OnConnect(botid, ip[], port)
{
new string[100];
printf(">> GarIRC v1.1: Bot ID %d connected (%d/"#MAX_BOTS") to %s (%d).", botid, botid, ip, port);
IRC_JoinChannel(botid, IRC_CHANNEL);
IRC_JoinChannel(botid, IRC_ECHO_CHANNEL);
IRC_JoinChannel(botid, IRC_AECHO_CHANNEL);
IRC_AddToGroup(gGroupID, botid);
format(string, sizeof(string), ""BOT_NICKNAME"[%d]", botid);
if(IRC_IsUserOnChannel(botid, IRC_CHANNEL, string))
{
format(string, sizeof(string), "ns ghost %s "BOT_PASSWORD"", string);
IRC_SendRaw(botid, string);
}
format(string, sizeof(string), ""BOT_NICKNAME"[%d]", botid);
IRC_ChangeNick(botid, string);
IRC_SendRaw(botid, "identify "BOT_PASSWORD"");
return 1;
}
public IRC_OnDisconnect(botid, ip[], port, reason[])
{
printf(">> GarIRC v1.1: Bot ID %d disconnected. Reason: %s.\n>> GarIRC v1.1: Attempting to reconnect to %s (%d)...", botid, reason, ip, port);
gBotID{(botid-1)} = 0;
IRC_RemoveFromGroup(gGroupID, botid);
return 1;
}
public IRC_OnKickedFromChannel(botid, channel[], oppeduser[], oppedhost[], message[])
{
IRC_GroupSayEx(gGroupID, IRC_AECHO_CHANNEL, "7[bot kicked] 3bot ID %d was kicked from the channel %s by %s (%s). Reason: %s.", botid, channel, oppeduser, oppedhost, message);
return 1;
}
public IRC_OnConnectAttemptFail(botid, ip[], port, reason[]) return printf(">> GarIRC v1.1: Bot ID %d failed to connect to %s (%d). Reason: %s.", botid, ip, port, reason);
#if COMMAND_TO_CHAT == false
public IRC_OnUserSay(botid, recipient[], user[], host[], message[])
{
#if VOICE_TO_CHAT == true
if(!IRC_IsVoice(botid, recipient, user)) return 0;
#endif
if(!strcmp(recipient, IRC_ECHO_CHANNEL))
{
if(message[0] == '!') return 1;
if(strfind(user, BOT_USERNAME) != -1) return 1;
SendMSGToAll(COLOUR_IRC, "%s on IRC:{FFFFFF} %s", user, message);
}
return 1;
}
#endif
public IRC_OnUserRequestCTCP(botid, user[], host[], message[])
{
if(!strcmp(message, "VERSION")) return IRC_ReplyCTCP(botid, user, "VERSION: GarIRC v1.1");
return 1;
}
//==============================================================================
// Functions
//==============================================================================
stock IsIRCChannel(channel[])
{
if(!strcmp(channel, IRC_ECHO_CHANNEL, true)) return 1;
else if(!strcmp(channel, IRC_AECHO_CHANNEL, true)) return 1;
else if(!strcmp(channel, IRC_CHANNEL, true)) return 1;
return 0;
}
stock IsIRCEchoChannel(channel[])
{
if(!strcmp(channel, IRC_ECHO_CHANNEL, true)) return 1;
else if(!strcmp(channel, IRC_AECHO_CHANNEL, true)) return 1;
return 0;
}
#if PNICK_FIX == true
stock pNick(playerid)
{
new uName[MAX_PLAYER_NAME];
GetPlayerName(playerid, uName, MAX_PLAYER_NAME);
return uName;
}
#else
stock pNick(playerid) return pName[playerid];
#endif
#if PIP_FIX == true
stock GetPlayerIpEx(playerid)
{
new uName[16];
GetPlayerIp(playerid, uIP, 16);
return uIP;
}
#else
stock GetPlayerIpEx(playerid) return PlayerIP[playerid];
#endif
stock GetDeathReason(killerid, reason)
{
new ReasonMsg[40], pstate = GetPlayerState(killerid), model = GetVehicleModel(GetPlayerVehicleID(killerid));
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:
{
if(pstate == PLAYER_STATE_DRIVER)
{
switch(model)
{
case 447: ReasonMsg = "Sea Sparrow Machine Gun";
default: ReasonMsg = "M4";
}
}
else ReasonMsg = "M4";
}
case 32: ReasonMsg = "TEC-9";
case 33: ReasonMsg = "Rifle";
case 34: ReasonMsg = "Sniper Rifle";
case 37: ReasonMsg = "Fire";
case 38:
{
if(pstate == PLAYER_STATE_DRIVER)
{
switch(model)
{
case 425: ReasonMsg = "Hunter Machine Gun";
default: ReasonMsg = "Minigun";
}
}
else ReasonMsg = "Minigun";
}
case 41: ReasonMsg = "Spraycan";
case 42: ReasonMsg = "Fire Extinguisher";
case 49: ReasonMsg = "Vehicle Collision";
case 50:
{
if(pstate == PLAYER_STATE_DRIVER)
{
switch(model)
{
case 417, 425, 447, 465, 469, 487, 488, 497, 501, 548, 563: ReasonMsg = "Helicopter Blades";
default: ReasonMsg = "Vehicle Collision";
}
}
else ReasonMsg = "Vehicle Collision";
}
case 51:
{
if(pstate == PLAYER_STATE_DRIVER)
{
switch(model)
{
case 425: ReasonMsg = "Hunter Rockets";
case 432: ReasonMsg = "Rhino Turret";
case 520: ReasonMsg = "Hydra Rockets";
default: ReasonMsg = "Explosion";
}
}
else ReasonMsg = "Explosion";
}
default: ReasonMsg = "Unknown";
}
}
if(killerid == INVALID_PLAYER_ID)
{
switch (reason)
{
case 53: ReasonMsg = "Drowned";
case 54: ReasonMsg = "Collision";
default: ReasonMsg = "Died";
}
}
return ReasonMsg;
}
//==============================================================================
// IRC Commands
//==============================================================================
IRCCMD:irccmds(botid, channel[], user[], host[], params[])
{
if(!strcmp(channel, IRC_ECHO_CHANNEL, true) || !strcmp(channel, IRC_AECHO_CHANNEL, true) || !strcmp(channel, IRC_CHANNEL, true))
{
IRC_GroupNotice(gGroupID, user, "IRC commands: !getname !getid !pm !players");
#if COMMAND_TO_CHAT == true && VOICE_TO_CHAT == true
if(IRC_IsVoice(botid, recipient, user))
{
IRC_GroupNotice(gGroupID, user, "IRC voice (+v) commands: !say");
}
#endif
if(IRC_IsHalfop(botid, channel, user))
{
IRC_GroupNotice(gGroupID, user, "IRC halfop (+h) commands: !admins");
}
if(IRC_IsOp(botid, channel, user))
{
IRC_GroupNotice(gGroupID, user, "IRC op (+o) commands: !asay !amsg !getinfo !akill !slap !iban !ikick");
}
if(IRC_IsAdmin(botid, channel, user))
{
IRC_GroupNotice(gGroupID, user, "IRC admin (+a) commands: !ssay");
}
if(IRC_IsOwner(botid, channel, user))
{
IRC_GroupNotice(gGroupID, user, "IRC owner (+q) commands: !restart !botjoin !botleave !botregister !botidentify !sendraw !sendrawall");
}
}
return 1;
}
IRCCMD:getid(botid, channel[], user[], host[], params[])
{
new name[MAX_PLAYER_NAME], count;
if(isnull(params) || strlen(params) > MAX_PLAYER_NAME) return IRC_GroupNotice(gGroupID, user, "4Usage: !getid (name: 3-"#MAX_PLAYER_NAME" characters)");
CMDSString = "";
foreach(Player, i)
{
GetPlayerName(i, name, MAX_PLAYER_NAME);
if(strfind(name, params) == -1) continue;
format(CMDSString, sizeof(CMDSString), "%s%s (%d), ", CMDSString, name, i);
count++;
}
switch(count)
{
case 0: IRC_GroupSayEx(gGroupID, channel, "No matches for \"%s\".", params);
default: IRC_GroupSayEx(gGroupID, channel, "Matches for \"%s\": %s", params, CMDSString);
}
return 1;
}
IRCCMD:getname(botid, channel[], user[], host[], params[])
{
new id;
if(!IsIRCChannel(channel)) return 0;
if(sscanf(params, "u", id)) return IRC_GroupNotice(gGroupID, user, "4Usage: !getname (nick/id)");
if(id == INVALID_PLAYER_ID) return IRC_GroupNotice(gGroupID, user, "4Invalid Player!");
IRC_GroupSayEx(gGroupID, channel, "02ID %d's name is %s", id, pNick(id));
return 1;
}
IRCCMD:pm(botid, channel[], user[], host[], params[])
{
new id, msg[61];
if(!IsIRCChannel(channel)) return 0;
if(sscanf(params, "us[60]", id, msg)) return IRC_GroupNotice(gGroupID, user, "4Usage: !pm (nick/id) (message: 1-60 characters)");
if(id == INVALID_PLAYER_ID) return IRC_GroupNotice(gGroupID, user, "4Invalid Player!");
if(isnull(msg) || msg[60]) return IRC_GroupNotice(gGroupID, user, "4Invalid length. The length must be between 1 and 60 characters.");
IRC_GroupSayEx(gGroupID, channel, "5PM sent to %s (%d): %s", pNick(id), id, msg);
SendMSG(id, COLOUR_PM, "PM from %s on IRC (%s):{FFFFFF} %s", user, channel, msg);
return 1;
}
IRCCMD:ssay(botid, channel[], user[], host[], params[])
{
if(!IRC_IsAdmin(botid, channel, user)) return 0;
if(!IsIRCChannel(channel)) return 0;
if(isnull(params) || strlen(params) > 60) return IRC_GroupNotice(gGroupID, user, "4Invalid length. The length must be between 1 and 60 characters.");
IRC_GroupSayEx(gGroupID, channel, "02*** Anonymous user on IRC (%s): %s", channel, params);
SendMSGToAll(COLOUR_IRC, "*** Anonymous user on IRC (%s): %s", channel, params);
return 1;
}
IRCCMD:asay(botid, channel[], user[], host[], params[])
{
if(!IRC_IsOp(botid, channel, user)) return 0;
if(!IsIRCChannel(channel)) return 0;
if(isnull(params) || strlen(params) > 60) return IRC_GroupNotice(gGroupID, user, "4Invalid length. The length must be between 1 and 60 characters.");
IRC_GroupSayEx(gGroupID, channel, "02*** Administrator %s on IRC: %s", user, params);
SendMSGToAll(COLOUR_ADMIN, "Administrator %s on IRC:{FFFFFF} %s", user, params);
return 1;
}
IRCCMD:say(botid, channel[], user[], host[], params[])
{
#if COMMAND_TO_CHAT == true
if(!IRC_IsOp(botid, channel, user)) return 0;
#endif
#if VOICE_TO_CHAT == true
if(!IRC_IsVoice(botid, channel, user)) return 0;
#endif
if(!IsIRCChannel(channel)) return 0;
#if SAY_ECHO_CHANNEL_ONLY == true
if(!IsIRCEchoChannel(channel) && !IRC_IsOp(botid, channel, user)) return 0;
#endif
if(isnull(params) || strlen(params) > 60) return IRC_GroupNotice(gGroupID, user, "4Invalid length. The length must be between 1 and 60 characters.");
IRC_GroupSayEx(gGroupID, channel, "02*** %s on IRC: %s", user, params);
SendMSGToAll(COLOUR_IRC, "%s on IRC:{FFFFFF} %s", user, params);
return 1;
}
IRCCMD:amsg(botid, channel[], user[], host[], params[])
{
if(!IRC_IsOp(botid, channel, user)) return 0;
if(strcmp(channel, IRC_AECHO_CHANNEL, true)) return 0;
if(isnull(params) || strlen(params) > 60) return IRC_GroupNotice(gGroupID, user, "4Invalid length. The length must be between 1 and 60 characters.");
foreach(Player, i)
{
if(!IsPlayerAdmin(i)) continue;
SendMSG(i, COLOUR_ADMIN, "(Admin Message) %s:{FFFFFF} %s", user, params);
}
IRC_GroupSayEx(gGroupID, channel, "5(Admin Message: %s): %s", user, params);
return 1;
}
IRCCMD:admins(botid, channel[], user[], host[], params[])
{
new count = 1;
if(!IRC_IsHalfop(botid, channel, user)) return 0;
if(!IsIRCChannel(channel)) return 0;
foreach(Player, i)
{
if(!IsPlayerAdmin(i)) continue;
IRC_GroupNoticeEx(gGroupID, user, "9%d. 7%s 5(%d)", count, pNick(i), i);
count++;
}
return 1;
}
IRCCMD:players(botid, channel[], user[], host[], params[])
{
if(!IsIRCChannel(channel)) return 0;
IRC_GroupNoticeEx(gGroupID, user, "Total players online: %d (%d of them are NPCs).", Itter_Count(Player), Itter_Count(Bot));
return 1;
}
IRCCMD:getinfo(botid, channel[], user[], host[], params[])
{
new id, Float:health[3];
if(!IRC_IsOp(botid, channel, user)) return 0;
if(!IsIRCChannel(channel)) return 0;
if(sscanf(params, "u", id)) return IRC_GroupNotice(gGroupID, user, "4Usage: !getinfo (nick/id)");
if(id == INVALID_PLAYER_ID) return IRC_GroupNotice(gGroupID, user, "4Invalid Player!");
GetPlayerHealth(id, health[0]), GetPlayerArmour(id, health[1]), GetVehicleHealth(GetPlayerVehicleID(id), health[2]);
IRC_GroupNoticeEx(gGroupID, user, "*** Player info for %s (%d) [IP: %s] ***", pNick(id), id, GetPlayerIpEx(id));
IRC_GroupNoticeEx(gGroupID, user, "Money (client wise): $%d. Score: %d. Ping: %d.", GetPlayerMoney(id), GetPlayerScore(id), GetPlayerPing(id));
IRC_GroupNoticeEx(gGroupID, user, "* Health: %0.2f. Armour: %0.2f. Vehicle Health: %0.2f.", health[0], health[1], health[2]);
return 1;
}
IRCCMD:akill(botid, channel[], user[], host[], params[])
{
new id, reason[51];
if(!IRC_IsOp(botid, channel, user)) return 0;
if(!IsIRCChannel(channel)) return 0;
if(sscanf(params, "uS(No Reason Specified)[50]", id, reason)) return IRC_GroupNotice(gGroupID, user, "4Usage: !akill (nick/id) (optional: reason)");
if(reason[50]) return IRC_GroupNotice(gGroupID, user, "4Invalid length. The length must be between 1 and 50 characters.");
if(id == INVALID_PLAYER_ID) return IRC_GroupNotice(gGroupID, user, "4Invalid Player!");
if(IsPlayerNPC(id) && !IRC_IsOwner(botid, channel, user)) return 0;
SetPlayerHealth(id, 0.00);
SendMSG(id, COLOUR_INFO, "Administrator %s on IRC (%s) has admin-killed you. Reason: %s.", user, channel, reason);
IRC_GroupNoticeEx(gGroupID, user, "You've admin-killed %s (%d). Reason: %s.", pNick(id), id, reason);
return 1;
}
IRCCMD:slap(botid, channel[], user[], host[], params[])
{
new id, Float:amount, reason[51], Float:Pos[3];
if(!IRC_IsOp(botid, channel, user)) return 0;
if(!IsIRCChannel(channel)) return 0;
if(sscanf(params, "uF(10.0)S(No Reason Specified)[50]", id, amount, reason)) return IRC_GroupNotice(gGroupID, user, "4Usage: !slap (nick/id) (optional: height) (optional: reason)");
if(reason[50]) return IRC_GroupNotice(gGroupID, user, "4Invalid length. The length must be between 1 and 50 characters.");
if(id == INVALID_PLAYER_ID) return IRC_GroupNotice(gGroupID, user, "4Invalid Player!");
if(IsPlayerNPC(id) && !IRC_IsOwner(botid, channel, user)) return 0;
GetPlayerPos(id, Pos[0], Pos[1], Pos[2]);
SetPlayerPos(id, Pos[0], Pos[1], (Pos[2] + amount));
SendMSG(id, COLOUR_INFO, "Administrator %s on IRC (%s) has slapped you. Reason: %s.", user, channel, reason);
IRC_GroupNoticeEx(gGroupID, user, "You've slapped %s (%d). Reason: %s.", pNick(id), id, reason);
return 1;
}
IRCCMD:iban(botid, channel[], user[], host[], params[])
{
new id, reason[51];
if(!IRC_IsOp(botid, channel, user)) return 0;
if(!IsIRCChannel(channel)) return 0;
if(sscanf(params, "uS(No Reason Specified)[50]", id, reason)) return IRC_GroupNotice(gGroupID, user, "4Usage: !iban (nick/id) (optional: reason)");
if(reason[50]) return IRC_GroupNotice(gGroupID, user, "4Invalid length. The length must be between 1 and 50 characters.");
if(id == INVALID_PLAYER_ID) return IRC_GroupNotice(gGroupID, user, "4Invalid Player!");
if(IsPlayerNPC(id) && !IRC_IsOwner(botid, channel, user)) return 0;
IRC_GroupNoticeEx(gGroupID, user, "You've banned %s (%d). Reason: %s.", pNick(id), id, reason);
SendMSGToAll(COLOUR_ADMIN, "*** %s (%d) has been banned from the server by %s on IRC. Reason: %s", pNick(id), id, user, reason);
return BanEx(id, reason);
}
IRCCMD:ikick(botid, channel[], user[], host[], params[])
{
new id, reason[51];
if(!IRC_IsOp(botid, channel, user)) return 0;
if(!IsIRCChannel(channel)) return 0;
if(sscanf(params, "uS(No Reason Specified)[50]", id, reason)) return IRC_GroupNotice(gGroupID, user, "4Usage: !ikick (nick/id) (optional: reason)");
if(reason[50]) return IRC_GroupNotice(gGroupID, user, "4Invalid length. The length must be between 1 and 50 characters.");
if(id == INVALID_PLAYER_ID) return IRC_GroupNotice(gGroupID, user, "4Invalid Player!");
if(IsPlayerNPC(id) && !IRC_IsOwner(botid, channel, user)) return 0;
IRC_GroupNoticeEx(gGroupID, user, "You've kicked %s (%d). Reason: %s.", pNick(id), id, reason);
SendMSGToAll(COLOUR_ADMIN, "*** %s (%d) has been kicked from the server by %s on IRC. Reason: %s", pNick(id), id, user, reason);
return Kick(id);
}
IRCCMD:restart(botid, channel[], user[], host[], params[])
{
if(!IRC_IsOwner(botid, channel, user)) return 0;
if(!IsIRCChannel(channel)) return 0;
return SendRconCommand("gmx");
}
IRCCMD:botjoin(botid, channel[], user[], host[], params[])
{
new chan[51], key[51];
if(!IRC_IsOwner(botid, channel, user)) return 0;
if(!IsIRCChannel(channel)) return 0;
if(sscanf(params, "s[50]S()[50]", chan, key)) return IRC_GroupNotice(gGroupID, user, "4Usage: !botjoin (#channel) (optional: channel key)");
if(strfind(chan, "#", true) == -1 || chan[50]) return IRC_GroupNotice(gGroupID, user, "4Usage: !botjoin (#channel) (optional: channel key)");
if(key[50]) return IRC_GroupNotice(gGroupID, user, "4Invalid channel key length. The length must be between 0 (no channel key) and 50 characters.");
switch(isnull(key))
{
case 0: IRC_GroupNoticeEx(gGroupID, user, "Attempting to join the channel %s...", chan);
default: IRC_GroupNoticeEx(gGroupID, user, "Attempting to join the channel %s with the key \"%s\"...", chan, key);
}
for(new bot = 1; bot <= MAX_BOTS; bot++)
{
IRC_JoinChannel(bot, chan, key);
}
return 1;
}
IRCCMD:botleave(botid, channel[], user[], host[], params[])
{
if(!IRC_IsOwner(botid, channel, user)) return 0;
if(!IsIRCChannel(channel)) return 0;
if(strfind(params, "#", true) == -1 || isnull(params)) return IRC_GroupNotice(gGroupID, user, "4Usage: !botleave (#channel)");
IRC_GroupNoticeEx(gGroupID, user, "Leaving channel %s...", params);
for(new bot = 1; bot <= MAX_BOTS; bot++)
{
IRC_PartChannel(bot, params);
}
return 1;
}
IRCCMD:botregister(botid, channel[], user[], host[], params[])
{
if(!IRC_IsOwner(botid, channel, user)) return 0;
if(!IsIRCChannel(channel)) return 0;
for(new bot = 1; bot <= MAX_BOTS; bot++)
{
switch(bot)
{
case 1: IRC_SendRaw(bot, "ns register "BOT_PASSWORD" "BOT_EMAIL"");
default: SetTimerEx("IRC_RegisterDelay", (IRC_REGISTER_DELAY * bot), false, "d", bot);
}
}
return IRC_GroupNotice(gGroupID, user, "Attempting to register the bots nicknames with password \""BOT_PASSWORD"\" and e-mail \""BOT_EMAIL"\".");
}
IRCCMD:botidentify(botid, channel[], user[], host[], params[])
{
if(!IRC_IsOwner(botid, channel, user)) return 0;
if(!IsIRCChannel(channel)) return 0;
for(new bot = 1; bot <= MAX_BOTS; bot++)
{
IRC_SendRaw(botid, "ns identify "BOT_PASSWORD"");
}
return IRC_GroupNotice(gGroupID, user, "Attempting to identify with nickserv using the password \""BOT_PASSWORD"\".");
}
IRCCMD:sendraw(botid, channel[], user[], host[], params[])
{
if(!IRC_IsOwner(botid, channel, user)) return 0;
if(!IsIRCChannel(channel)) return 0;
new iBotID, rawmsg[81];
if(sscanf(params, "ds[80]", iBotID, rawmsg)) return IRC_GroupNotice(gGroupID, user, "4Usage: !sendraw (bot ID) (raw message)");
if(rawmsg[80]) return IRC_GroupNotice(gGroupID, user, "Invalid length of raw message. The raw message can only be between 1 and 80 characters.");
IRC_SendRaw(gBotID[iBotID], rawmsg);
IRC_GroupNoticeEx(gGroupID, user, "Raw message \"%s\" has been sent to the irc server using bot ID %d.", params, iBotID);
return 1;
}
IRCCMD:sendrawall(botid, channel[], user[], host[], params[])
{
if(!IRC_IsOwner(botid, channel, user)) return 0;
if(!IsIRCChannel(channel)) return 0;
if(isnull(params)) return IRC_GroupNotice(gGroupID, user, "4Usage: !sendrawall (raw message)");
if(strlen(params) > 80) return IRC_GroupNotice(gGroupID, user, "Invalid length of raw message. The raw message can only be between 1 and 80 characters.");
for(new bot = 1; bot <= MAX_BOTS; bot++)
{
IRC_SendRaw(botid, params);
}
IRC_GroupNoticeEx(gGroupID, user, "Raw message \"%s\" has been sent to the irc server using all IRC bots.", params);
return 1;
}
//==============================================================================
// In-game commands
//==============================================================================
CMD:irc(playerid, params[])
{
if(isnull(params)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /irc (message)");
if(strlen(params) > 80) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid length. The length must be between 1 and 80 characters.");
IRC_GroupSayEx(gGroupID, IRC_ECHO_CHANNEL, "5Message from %s (%d) in-game: %s", pNick(playerid), playerid, params);
SendClientMessage(playerid, COLOUR_INFO, "Your message has been sent to IRC (channel: "IRC_ECHO_CHANNEL").");
return 1;
}
CMD:ircpm(playerid, params[])
{
new user[31], msg[61];
if(sscanf(params, "s[30]s[60]", user, msg)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /ircpm (user) (message)");
if(user[30] || (!IRC_IsUserOnChannel(gBotID{0}, IRC_ECHO_CHANNEL, user) && !IRC_IsUserOnChannel(gBotID{0}, IRC_CHANNEL, user) && !IRC_IsUserOnChannel(gBotID{0}, IRC_AECHO_CHANNEL, user))) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid user. There is no user connected to IRC with that name.");
if(msg[60]) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid length. The length must be between 1 and 60 characters.");
IRC_GroupNoticeEx(gGroupID, user, "5PM from %s (%d) in-game: %s", pNick(playerid), playerid, msg);
SendMSG(playerid, COLOUR_INFO, "Your message has been sent to %s on IRC.", user);
return 1;
}