Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////////////////
- // //
- // IRC Administrator Basic 1.0 by PlayerX //
- // //
- // Available commands: //
- // - For ALL //
- // !say <Message> o !msg <Message> //
- // !pm <PlayerName/PlayerID> <Message> //
- // !players //
- // !getid <PartOfName> //
- // - For Op (Operator) //
- // !kick <PlayerName/PlayerID> <Reason[optional]> //
- // !ban <PlayerName/PlayerID> <Reason[Optional]> //
- // !slap <PlayerName/PlayerID> <Reason[Optional]> //
- // !kill <PlayerName/PlayerID> <Reason[Optional]> //
- // //
- ////////////////////////////////////////////////////////////////////////////////
- new IrcServer[40] = "irc.gtanet.com";
- new IrcPort = 6667;
- #define EchoChan "#changeme"
- #define Echochan "#changeme"
- #define OP_CHAN "@#changeme"
- new BotName[40] = "changeme";
- #define NSpassword "changeme"
- #include <a_samp>
- #define irccmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (irccmd_%1(botid,recipient,user,"")))||(((%3)[(%2) + 1] == 32) && (irccmd_%1(botid,recipient,user,(%3)[(%2) + 2]))))) return 1
- #define green 0x33AA33AA
- #define red 0xAA3333AA
- #define orange 0xFF8040FF
- native IRC_Connect(const server[], port, const nickname[], const realname[], const username[]);
- native IRC_Quit(botid, const message[] = "");
- native IRC_JoinChannel(botid, const channel[], const key[] = "");
- native IRC_PartChannel(botid, const channel[], const message[] = "");
- native IRC_ChangeNick(botid, const nick[]);
- native IRC_SetMode(botid, const target[], const mode[]);
- native IRC_Say(botid, const target[], const message[]);
- native IRC_Notice(botid, const target[], const message[]);
- native IRC_IsUserOnChannel(botid, const channel[], const user[]);
- native IRC_InviteUser(botid, const channel[], const user[]);
- native IRC_KickUser(botid, const channel[], const user[], const message[] = "");
- native IRC_GetUserChannelMode(botid, const channel[], const user[], dest[]);
- native IRC_GetChannelUserList(botid, const channel[], dest[], maxlength = sizeof dest);
- native IRC_SetChannelTopic(botid, const channel[], const topic[]);
- native IRC_SendRaw(botid, const message[]);
- native IRC_CreateGroup();
- native IRC_DestroyGroup(groupid);
- native IRC_AddToGroup(groupid, botid);
- native IRC_RemoveFromGroup(groupid, botid);
- native IRC_GroupSay(groupid, const target[], const message[]);
- native IRC_GroupNotice(groupid, const target[], const message[]);
- // Callbacks
- forward IRC_OnConnect(botid);
- forward IRC_OnDisconnect(botid);
- forward IRC_OnJoinChannel(botid, channel[]);
- forward IRC_OnLeaveChannel(botid, channel[], message[]);
- forward IRC_OnUserDisconnect(botid, user[], host[], message[]);
- forward IRC_OnUserJoinChannel(botid, channel[], user[], host[]);
- forward IRC_OnUserLeaveChannel(botid, channel[], user[], host[], message[]);
- forward IRC_OnUserNickChange(botid, oldnick[], newnick[], host[]);
- forward IRC_OnUserSetChannelMode(botid, channel[], user[], host[], mode[]);
- forward IRC_OnUserSetChannelTopic(botid, channel[], user[], host[], topic[]);
- forward IRC_OnUserSay(botid, recipient[], user[], host[], message[]);
- forward IRC_OnUserNotice(botid, recipient[], user[], host[], message[]);
- forward IRC_OnReceiveRaw(botid, message[]);
- new EchoConnection;
- new Delay = 5000;
- forward IrcConnect();
- forward IrcLoggin();
- new aDisconnectNames[][20] = {
- {"7Timeout2"},
- {"3Leaving2"},
- {"4Kicked/Banned2"}
- };
- public OnFilterScriptInit()
- {
- EchoConnection = IRC_Connect(IrcServer, IrcPort, BotName, "IAdministrator Basic 1.0", "IABot");
- return true;
- }
- public IrcConnect()
- {
- return 1;
- }
- public OnFilterScriptExit()
- {
- IRC_Quit(EchoConnection, "12* Bot Disconnected,cya");
- return true;
- }
- public IRC_OnConnect(botid)
- {
- SetTimer("IrcLoggin", 3000, 1);
- IRC_JoinChannel(EchoConnection, EchoChan);
- return 1;
- }
- public IRC_OnDisconnect(botid)
- {
- SetTimer("IrcConnect", Delay,1);
- return 1;
- }
- public IrcLoggin()
- {
- new msg[100];
- format(msg, sizeof(msg), "ns identify %s", NSpassword);
- IRC_SendRaw(EchoConnection, msg);
- return 1;
- }
- public IRC_OnJoinChannel(botid, channel[])
- {
- if(strcmp(channel, EchoChan, true) == 0)
- {
- new msg[100], msg1[100];
- GetServerVarAsString("hostname", msg1, sizeof(msg1));
- format(msg, sizeof(msg), "3*** %s has connected to %s", BotName, msg1);
- IRC_Say(EchoConnection, EchoChan, msg);
- }
- return 1;
- }
- public IRC_OnLeaveChannel(botid, channel[], message[])
- {
- if(strcmp(channel, EchoChan, true) == 0)
- {
- IRC_JoinChannel(EchoConnection,EchoChan);
- }
- return 1;
- }
- public IRC_OnUserSay(botid, recipient[], user[], host[], message[])
- {
- if ((message[0] != '!')) return true;
- new space = (strfind(message, " "));
- new cmdlen;
- if (space>=1)
- {
- new lenmsg = strlen(message);
- cmdlen = ((lenmsg-(lenmsg-space))-1);
- }
- else
- {
- cmdlen = (strlen(message)-1);
- }
- if (cmdlen == 2)
- {
- irccmd(pm,2,botid,recipient,user,message);
- }
- if (cmdlen == 3)
- {
- irccmd(say,3,botid,recipient,user,message);
- irccmd(msg,3,botid,recipient,user,message);
- irccmd(ban,3,botid,recipient,user,message);
- }
- if (cmdlen == 4)
- {
- irccmd(kick,4,botid,recipient,user,message);
- irccmd(slap,4,botid,recipient,user,message);
- irccmd(kill,4,botid,recipient,user,message);
- irccmd(cmds,4,botid,recipient,user,message);
- }
- if (cmdlen == 5)
- {
- irccmd(getid,5,botid,recipient,user,message);
- }
- if (cmdlen == 6)
- {
- irccmd(disarm,6,botid,recipient,user,message);
- }
- if (cmdlen == 7)
- {
- irccmd(players,7,botid,recipient,user,message);
- irccmd(setname,7,botid,recipient,user,message);
- irccmd(explode,7,botid,recipient,user,message);
- }
- if(cmdlen == 9)
- {
- irccmd(givemoney,9,botid,recipient,user,message);
- irccmd(sethealth,9,botid,recipient,user,message);
- }
- if(cmdlen == 10)
- {
- irccmd(giveweapon,10,botid,recipient,user,message);
- }
- return true;
- }
- #define IRC_OPcmds "!kick !ban !slap !kill !sethealth !explode !setname !disarm !giveweapon !givemoney"
- #define IRC_REGcmds "!say !pm !players !getid !cmds"
- irccmd_cmds(conn, channel[], user[], params[])
- {
- #pragma unused params
- new string[128];
- if(IsPlayerOp(conn,channel,user))
- {
- format(string, sizeof(string), "1%s", IRC_OPcmds);
- IRC_Say(EchoConnection, OP_CHAN, string);
- format(string, sizeof(string), "1%s", IRC_REGcmds);
- IRC_Say(EchoConnection, OP_CHAN, string);
- }
- else
- {
- format(string, sizeof(string), "1%s", IRC_REGcmds);
- IRC_Say(EchoConnection, EchoChan, string);
- }
- return 1;
- }
- irccmd_pm(conn, channel[], user[], params[])
- {
- new giveid,msg[256],lolz1[256], lolz2[256], pon[100];
- if(sscanf(params,"ss",pon,msg)) return IRC_Say(EchoConnection, EchoChan,"3Usage: !pm <PartOfName/PlayerID> <Message>");
- giveid = ReturnUser(pon);
- if(!IsPlayerConnected(giveid))return IRC_Say(EchoConnection, EchoChan,"4*** Error: Invalid player ID.");
- format(lolz1,256, "*** Pm from %s (IRC): %s",user, msg);
- format(lolz2,256, "5*** Pm to %s (ID:%d): %s",PlayerName(giveid),giveid,msg);
- SendClientMessage(giveid,green,lolz1);
- IRC_Say(EchoConnection, EchoChan, lolz2);
- #pragma unused conn, channel
- return true;
- }
- irccmd_say(conn, channel[], user[], params[])
- {
- if(!strlen(params)) return IRC_Say(EchoConnection,channel,"3Usage: !say <Message>");
- new lolz1[256], lolz2[256];
- if(IsPlayerOwner(conn,channel,user))
- {
- format(lolz1,256,"* Admin %s on irc: %s",user,params);
- SendClientMessageToAll(orange, lolz1);
- format(lolz2,256,"2* Admin %s on irc: %s",user,params);
- IRC_Say(EchoConnection,channel,lolz2);
- return true;
- }
- else if(IsPlayerSop(conn,channel,user))
- {
- format(lolz1,256,"* Admin %s on irc: %s",user,params);
- SendClientMessageToAll(orange, lolz1);
- format(lolz2,256,"2* Admin %s on irc: %s",user,params);
- IRC_Say(EchoConnection,channel,lolz2);
- return true;
- }
- else if(IsPlayerOp(conn,channel,user))
- {
- format(lolz1,256,"* Admin %s on irc: %s",user,params);
- SendClientMessageToAll(orange, lolz1);
- format(lolz2,256,"2* Admin %s on irc: %s",user,params);
- IRC_Say(EchoConnection,channel,lolz2);
- return true;
- }
- else if(IsPlayerHop(conn,channel,user))
- {
- format(lolz1,256,"* Mod %s on irc: %s",user,params);
- SendClientMessageToAll(orange, lolz1);
- format(lolz2,256,"2* Mod %s on irc: %s",user,params);
- IRC_Say(EchoConnection,channel,lolz2);
- return true;
- }
- else if(IsPlayerVoi(conn,channel,user))
- {
- format(lolz1,256,"* Guest %s on irc: %s",user,params);
- SendClientMessageToAll(orange, lolz1);
- format(lolz2,256,"2* Guest %s on irc: %s",user,params);
- IRC_Say(EchoConnection,channel,lolz2);
- return true;
- }
- format(lolz1,256,"* Guest %s on irc: %s",user,params);
- SendClientMessageToAll(orange, lolz1);
- format(lolz2,256,"2* Guest %s on irc: %s",user,params);
- IRC_Say(EchoConnection,channel,lolz2);
- #pragma unused conn
- return true;
- }
- irccmd_msg(conn, channel[], user[], params[])
- {
- if(!strlen(params)) return IRC_Say(EchoConnection,channel,"3Usage: !msg <Message>");
- new lolz1[256], lolz2[256];
- if(IsPlayerOwner(conn,channel,user))
- {
- format(lolz1,256,"* Admin %s on irc: %s",user,params);
- SendClientMessageToAll(orange, lolz1);
- format(lolz2,256,"2* Admin %s on irc: %s",user,params);
- IRC_Say(EchoConnection,channel,lolz2);
- return true;
- }
- else if(IsPlayerSop(conn,channel,user))
- {
- format(lolz1,256,"* Admin %s on irc: %s",user,params);
- SendClientMessageToAll(orange, lolz1);
- format(lolz2,256,"2* Admin %s on irc: %s",user,params);
- IRC_Say(EchoConnection,channel,lolz2);
- return true;
- }
- else if(IsPlayerOp(conn,channel,user))
- {
- format(lolz1,256,"* Admin %s on irc: %s",user,params);
- SendClientMessageToAll(orange, lolz1);
- format(lolz2,256,"2* Admin %s on irc: %s",user,params);
- IRC_Say(EchoConnection,channel,lolz2);
- return true;
- }
- else if(IsPlayerHop(conn,channel,user))
- {
- format(lolz1,256,"* Mod %s on irc: %s",user,params);
- SendClientMessageToAll(orange, lolz1);
- format(lolz2,256,"2* Mod %s on irc: %s",user,params);
- IRC_Say(EchoConnection,channel,lolz2);
- return true;
- }
- else if(IsPlayerVoi(conn,channel,user))
- {
- format(lolz1,256,"* Guest %s on irc: %s",user,params);
- SendClientMessageToAll(orange, lolz1);
- format(lolz2,256,"2* Guest %s on irc: %s",user,params);
- IRC_Say(EchoConnection,channel,lolz2);
- return true;
- }
- format(lolz1,256,"* Guest %s on irc: %s",user,params);
- SendClientMessageToAll(orange, lolz1);
- format(lolz2,256,"2* Guest %s on irc: %s",user,params);
- IRC_Say(EchoConnection,channel,lolz2);
- #pragma unused conn
- return true;
- }
- irccmd_ban(conn, channel[], user[], params[])
- {
- new giveid,msg[255],sayban[255], bansay[256], pon[100];
- if(!IsPlayerOp(conn,channel,user)) return AccessDenied(user);
- if(sscanf(params, "sz",pon,msg)) return IRC_Say(EchoConnection,channel,"3Usage: !ban <PartOfName/PlayerID> <Reason [Optional]>");
- giveid = ReturnUser(pon);
- if(!IsPlayerConnected(giveid)) return IRC_Say(EchoConnection,channel,"4*** Error: Invalid Player ID");
- format(sayban,sizeof(sayban),"*** Admin %s (IRC) banned player %s (ID:%d), Reason: %s.",user,PlayerName(giveid),giveid,msg[0] ? msg: "None");
- format(bansay,sizeof(bansay),"4*** Admin %s (IRC) banned player %s (ID:%d), Reason: %s.",user,PlayerName(giveid),giveid,msg[0] ? msg: "None");
- SendClientMessageToAll(red,sayban);
- IRC_Say(EchoConnection,channel,bansay);
- BanEx(giveid,msg);
- #pragma unused conn
- return true;
- }
- irccmd_kick(conn, channel[], user[], params[])
- {
- new giveid,msg[255],saykick[255],kicksay[256],pon[100];
- if(!IsPlayerOp(conn,channel,user)) return AccessDenied(user);
- if(sscanf(params, "sz", pon,msg)) return IRC_Say(EchoConnection,channel,"3Usage: !kick <PartOfName/PlayerID> <Reason [Optional]>");
- giveid = ReturnUser(pon);
- if(!IsPlayerConnected(giveid)) return IRC_Say(EchoConnection,channel,"4*** Error: Invalid Player ID");
- format(saykick,sizeof(saykick),"*** Admin %s (IRC) kicked player %s (ID:%d), Reason: %s.",user,PlayerName(giveid),giveid,msg[0] ? msg: "None");
- format(kicksay,sizeof(kicksay),"4*** Admin %s (IRC) kicked player %s (ID:%d), Reason: %s.",user,PlayerName(giveid),giveid,msg[0] ? msg: "None");
- SendClientMessageToAll(red,saykick);
- IRC_Say(EchoConnection,channel,kicksay);
- Kick(giveid);
- #pragma unused conn
- return true;
- }
- irccmd_kill(conn, channel[], user[], params[])
- {
- new giveid,msg[255],lolz1[255],lolz2[256],pon[100];
- if(!IsPlayerHop(conn,channel,user)) return AccessDenied(user);
- if(sscanf(params,"sz",pon,msg)) return IRC_Say(EchoConnection,channel,"3Usage: !kill <PartOfName/PlayerID> <Reason [Optional]>");
- giveid = ReturnUser(pon);
- if(!IsPlayerConnected(giveid)) return IRC_Say(EchoConnection,channel,"4*** Error: Invalid Player ID");
- SetPlayerHealth(giveid,0);
- SetPlayerArmour(giveid,0);
- format(lolz1,sizeof(lolz1),"*** Admin %s (IRC) killed player %s (ID:%d), Reason: %s.",user,PlayerName(giveid),giveid,msg[0] ? msg: "None");
- format(lolz2,sizeof(lolz2),"4*** Admin %s (IRC) killed player %s (ID:%d), Reason: %s.",user,PlayerName(giveid),giveid,msg[0] ? msg: "None");
- SendClientMessageToAll(red,lolz1);
- IRC_Say(EchoConnection,channel,lolz2);
- #pragma unused conn
- return true;
- }
- irccmd_slap(conn, channel[], user[], params[])
- {
- new giveid,lolz1[256],lolz2[256],msg[256],pon[100];
- if(!IsPlayerHop(conn,channel,user)) return AccessDenied(user);
- if(sscanf(params,"sz",pon,msg)) return IRC_Say(EchoConnection,channel,"3Usage: !slap <PartOfName/PlayerID> <Reason [Optional]>");
- giveid = ReturnUser(pon);
- if(!IsPlayerConnected(giveid))return IRC_Say(EchoConnection,channel,"4*** Error: Invalid player ID.");
- new Float:slx, Float:sly, Float:slz;
- new Float:shealth;
- GetPlayerHealth(giveid, shealth);
- SetPlayerHealth(giveid, shealth-15);
- GetPlayerPos(giveid, slx, sly, slz);
- SetPlayerPos(giveid, slx+5, sly, slz);
- format(lolz1,256,"4*** Admin %s (IRC) slaps player %s (ID:%d), Reason: %s.",user,PlayerName(giveid),giveid,msg[0] ? msg: "None");
- format(lolz2,256,"*** Admin %s (IRC) slaps player %s (ID:%d), Reason: %s.",user,PlayerName(giveid),giveid,msg[0] ? msg: "None");
- IRC_Say(EchoConnection,channel,lolz1);
- SendClientMessageToAll(red,lolz2);
- #pragma unused conn
- return true;
- }
- irccmd_getid(conn, channel[], user[], params[])
- {
- new GetPlayer[256],giveid,lolz1[256],lolz2[256];
- if(sscanf(params,"s",GetPlayer)) return IRC_Say(EchoConnection,channel,"3Usage: !getid <PartOfName>");
- for (giveid=0; giveid<=MAX_PLAYERS; giveid++)
- {
- if (IsPlayerConnected(giveid))
- {
- GetPlayerName(giveid,GetPlayer,16);
- new space = (strfind(GetPlayer, params));
- if (space != -1)
- {
- format(lolz1, sizeof(lolz1), "3*** Player whose name is %s has the ID: %d", GetPlayer, giveid);
- IRC_Say(EchoConnection,channel,lolz1);
- return true;
- }
- }
- }
- format(lolz2, sizeof(lolz2),"4*** Error: Invalid Name", params[0]);
- IRC_Say(EchoConnection,channel,lolz2);
- #pragma unused conn,user
- return true;
- }
- irccmd_players(conn, channel[], user[], params[])
- {
- new count1;
- new PlayerNames[512];
- new msg[512];
- for(new i=0; i<=MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(count1 == 0)
- {
- new PlayerName1[MAX_PLAYER_NAME];
- GetPlayerName(i, PlayerName1, sizeof(PlayerName1));
- format(PlayerNames, sizeof(PlayerNames),"[%d] %s",i,PlayerName1);
- count1++;
- }
- else
- {
- new PlayerName1[MAX_PLAYER_NAME];
- GetPlayerName(i, PlayerName1, sizeof(PlayerName1));
- format(PlayerNames, sizeof(PlayerNames),"%s, [%d] %s",PlayerNames,i,PlayerName1);
- count1++;
- }
- }
- else { if(count1 == 0) format(PlayerNames, sizeof(PlayerNames),"No Players Online"); }
- }
- new counter1 = 0;
- new players = GetMaxPlayers();
- for(new i=0; i<=MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i)) counter1++;
- }
- format(msg,512,"3*** Players Online [%d/%d]: %s",counter1,players,PlayerNames);
- IRC_Say(EchoConnection,channel,msg);
- #pragma unused params,user,conn
- return true;
- }
- irccmd_giveweapon(conn, channel[], user[], params[])
- {
- new string[128],
- ID,
- weapid,
- ammo;
- if(sscanf(params, "iii", ID, weapid, ammo))
- return IRC_Say(EchoConnection, EchoChan, "Use: !giveweapon [ID] [WEPID] [AMMO]");
- if(!IsPlayerOp(conn,channel,user))
- return AccessDenied(user);
- if(!IsPlayerConnected(ID))
- return IRC_Say(EchoConnection, EchoChan,"4*** Error: Invalid player ID.");
- GivePlayerWeapon(ID, weapid, ammo);
- new oname[MAX_PLAYER_NAME];
- GetPlayerName(ID, oname, sizeof(oname));
- new weapname[24];
- GetWeaponName(weapid, weapname, 32);
- format(string, sizeof(string), "%s has been given a %d with %d ammo by IRC admin %s", oname, weapname, ammo, user);
- SendClientMessageToAll(red, string);
- IRC_Say(EchoConnection,channel,string);
- return 1;
- }
- irccmd_givemoney(conn, channel[], user[], params[])
- {
- new string[128],
- ID,
- amount;
- if(sscanf(params, "ii", ID, amount))
- return IRC_Say(EchoConnection, EchoChan, "Use: !givemoney [ID] [AMMOUNT]");
- if(!IsPlayerOp(conn,channel,user))
- return AccessDenied(user);
- if(!IsPlayerConnected(ID))
- return IRC_Say(EchoConnection, EchoChan,"4*** Error: Invalid player ID.");
- GivePlayerMoney(ID, amount);
- new oname[MAX_PLAYER_NAME];
- GetPlayerName(ID, oname, sizeof(oname));
- format(string, sizeof(string), "\"%s\" has been given $%d by IRC admin \"%s\"", oname, amount, user);
- SendClientMessageToAll(red, string);
- IRC_Say(EchoConnection,channel,string);
- return 1;
- }
- irccmd_setname(conn, channel[], user[], params[])
- {
- new string[128],
- ID,
- newname[32];
- if(sscanf(params, "is", ID, newname))
- return IRC_Say(EchoConnection, EchoChan, "Use: !setname [ID] [NAME]");
- if(!IsPlayerOp(conn,channel,user))
- return AccessDenied(user);
- if(!IsPlayerConnected(ID))
- return IRC_Say(EchoConnection, EchoChan,"4*** Error: Invalid player ID.");
- new oname[MAX_PLAYER_NAME];
- GetPlayerName(ID, oname, sizeof(oname));
- format(string, sizeof(string), "%s has had his name set to %s by IRC admin %s", oname, newname, user);
- SetPlayerName(ID, newname);
- SendClientMessageToAll(red, string);
- IRC_Say(EchoConnection,channel,string);
- return 1;
- }
- irccmd_sethealth(conn, channel[], user[], params[])
- {
- new string[128],
- ID,
- health;
- if(sscanf(params, "is", ID, health))
- return IRC_Say(EchoConnection, EchoChan, "Use: !sethealth [ID] [HEALTH]");
- if(!IsPlayerOp(conn,channel,user))
- return AccessDenied(user);
- if(!IsPlayerConnected(ID))
- return IRC_Say(EchoConnection, EchoChan,"4*** Error: Invalid player ID.");
- SetPlayerHealth(ID, health);
- new oname[MAX_PLAYER_NAME];
- GetPlayerName(ID, oname, sizeof(oname));
- format(string, sizeof(string), "%s has had thier health set to %.0f by IRC admin %s", oname, health, user);
- SendClientMessageToAll(red, string);
- IRC_Say(EchoConnection,channel,string);
- return 1;
- }
- irccmd_disarm(conn, channel[], user[], params[])
- {
- new string[128],
- ID;
- if(sscanf(params, "i", ID))
- return IRC_Say(EchoConnection, EchoChan, "Use: !disarm [ID]");
- if(!IsPlayerOp(conn,channel,user))
- return AccessDenied(user);
- if(!IsPlayerConnected(ID))
- return IRC_Say(EchoConnection, EchoChan,"4*** Error: Invalid player ID.");
- ResetPlayerWeapons(ID);
- new oname[MAX_PLAYER_NAME];
- GetPlayerName(ID, oname, sizeof(oname));
- format(string, sizeof(string), "%s has had their weapons reset by IRC admin %s", oname, user);
- SendClientMessageToAll(red, string);
- IRC_Say(EchoConnection,channel,string);
- return 1;
- }
- irccmd_explode(conn, channel[], user[], params[])
- {
- new string[128],
- ID;
- if(sscanf(params, "i", ID))
- return IRC_Say(EchoConnection, EchoChan, "Use: !explode [ID]");
- if(!IsPlayerOp(conn,channel,user))
- return AccessDenied(user);
- if(!IsPlayerConnected(ID))
- return IRC_Say(EchoConnection, EchoChan,"4*** Error: Invalid player ID.");
- new Float:x, Float:y, Float:z;
- GetPlayerPos(ID, x, y, z);
- CreateExplosion(x, y, z, 10, 0);
- new oname[MAX_PLAYER_NAME];
- GetPlayerName(ID, oname, sizeof(oname));
- format(string, sizeof(string), "%s has been exploded by IRC admin %s", oname, user);
- SendClientMessageToAll(red, string);
- IRC_Say(EchoConnection,channel,string);
- 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 '\0':
- {
- return 0;
- }
- case 'i', 'd':
- {
- new
- neg = 1,
- num = 0,
- ch = string[stringPos];
- if (ch == '-')
- {
- neg = -1;
- ch = string[++stringPos];
- }
- do
- {
- stringPos++;
- if (ch >= '0' && ch <= '9')
- {
- num = (num * 10) + (ch - '0');
- }
- else
- {
- return 1;
- }
- }
- while ((ch = string[stringPos]) && ch != ' ');
- setarg(paramPos, 0, num * neg);
- }
- case 'h', 'x':
- {
- new
- ch,
- num = 0;
- while ((ch = string[stringPos++]))
- {
- switch (ch)
- {
- case 'x', 'X':
- {
- num = 0;
- continue;
- }
- case '0' .. '9':
- {
- num = (num << 4) | (ch - '0');
- }
- case 'a' .. 'f':
- {
- num = (num << 4) | (ch - ('a' - 10));
- }
- case 'A' .. 'F':
- {
- num = (num << 4) | (ch - ('A' - 10));
- }
- case ' ':
- {
- break;
- }
- default:
- {
- return 1;
- }
- }
- }
- setarg(paramPos, 0, num);
- }
- case 'c':
- {
- setarg(paramPos, 0, string[stringPos++]);
- }
- case 'f':
- {
- new tmp[25];
- strmid(tmp, string, stringPos, stringPos+sizeof(tmp)-2);
- setarg(paramPos, 0, _:floatstr(tmp));
- }
- case 's', 'z':
- {
- new
- i = 0,
- ch;
- if (format[formatPos])
- {
- while ((ch = string[stringPos++]) && ch != ' ')
- {
- setarg(paramPos, i++, ch);
- }
- if (!i) return 1;
- }
- else
- {
- while ((ch = string[stringPos++]))
- {
- setarg(paramPos, i++, ch);
- }
- }
- stringPos--;
- setarg(paramPos, i, '\0');
- }
- default:
- {
- continue;
- }
- }
- while (string[stringPos] && string[stringPos] != ' ')
- {
- stringPos++;
- }
- while (string[stringPos] == ' ')
- {
- stringPos++;
- }
- paramPos++;
- }
- while (format[formatPos] == 'z') formatPos++;
- return format[formatPos];
- }
- IsNumeric(const string[])
- {
- for (new i = 0, j = strlen(string); i < j; i++)
- {
- if (string[i] > '9' || string[i] < '0') return 0;
- }
- return 1;
- }
- ReturnUser(text[])
- {
- new pos = 0;
- while (text[pos] < 0x21)
- {
- if (text[pos] == 0) return INVALID_PLAYER_ID;
- pos++;
- }
- new userid = INVALID_PLAYER_ID;
- if (IsNumeric(text[pos]))
- {
- userid = strval(text[pos]);
- if (userid >=0 && userid < MAX_PLAYERS)
- {
- if(!IsPlayerConnected(userid))
- {
- userid = INVALID_PLAYER_ID;
- }
- else
- {
- return userid;
- }
- }
- }
- new giveid;
- new GetPlayer[256];
- for (giveid=0; giveid<=MAX_PLAYERS; giveid++)
- {
- if (IsPlayerConnected(giveid))
- {
- GetPlayerName(giveid,GetPlayer,16);
- new space = (strfind(GetPlayer, text,true));
- if (space != -1)
- {
- return giveid;
- }
- }
- }
- return userid;
- }
- forward AccessDenied(user[]);
- public AccessDenied(user[])
- {
- new Denied[256];
- format(Denied,sizeof(Denied),"Notice %s 4*** Error: You don't have the necessary level.",user);
- IRC_Notice(EchoConnection,user,Denied);
- return true;
- }
- stock PlayerName(playerid)
- {
- new name[255];
- GetPlayerName(playerid, name, 255);
- return name;
- }
- stock IsPlayerVoi(conn,channel[],user[])
- {
- new ircLevel[5];
- IRC_GetUserChannelMode(conn, channel, user, ircLevel);
- if(!strcmp(ircLevel, ".", true,1) || !strcmp(ircLevel, "~", true,1) || !strcmp(ircLevel, "&", true,1) || !strcmp(ircLevel, "@", true,1) || !strcmp(ircLevel, "%", true,1) || !strcmp(ircLevel, "+", true,1)) return true;
- return false;
- }
- stock IsPlayerHop(conn,channel[],user[])
- {
- new ircLevel[5];
- IRC_GetUserChannelMode(conn, channel, user, ircLevel);
- if(!strcmp(ircLevel, ".", true,1) || !strcmp(ircLevel, "~", true,1) || !strcmp(ircLevel, "&", true,1) || !strcmp(ircLevel, "@", true,1) || !strcmp(ircLevel, "%", true,1)) return true;
- return false;
- }
- stock IsPlayerOp(conn,channel[],user[])
- {
- new ircLevel[5];
- IRC_GetUserChannelMode(conn, channel, user, ircLevel);
- if(!strcmp(ircLevel, ".", true,1) || !strcmp(ircLevel, "~", true,1) || !strcmp(ircLevel, "&", true,1) || !strcmp(ircLevel, "@", true,1)) return true;
- return false;
- }
- stock IsPlayerSop(conn, channel[], user[])
- {
- new playerlevel[5];
- IRC_GetUserChannelMode(conn, channel, user, playerlevel);
- if(!strcmp(playerlevel, ".", true,1) || !strcmp(playerlevel, "~", true,1) || !strcmp(playerlevel, "&", true,1)) return true;
- return false;
- }
- stock IsPlayerOwner(conn, channel[], user[])
- {
- new playerlevel[5];
- IRC_GetUserChannelMode(conn, channel, user, playerlevel);
- if(!strcmp(playerlevel, ".", true,1) || !strcmp(playerlevel, "~", true,1)) return true;
- return false;
- }
- public OnPlayerConnect(playerid)
- {
- new JoinMsg1[128];
- format(JoinMsg1,128, "6** 5[%i]3 %s has joined the server.", playerid, PlayerName(playerid));
- IRC_Say(EchoConnection, EchoChan, JoinMsg1);
- return true;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new leaveMsg1[256];
- format(leaveMsg1, 256, "6** 4[%i]2 %s has left the server. (%s)", playerid, PlayerName(playerid), aDisconnectNames[reason]);
- IRC_Say(EchoConnection, EchoChan, leaveMsg1);
- return true;
- }
- public OnPlayerText(playerid, text[])
- {
- new playertext[256];
- if(IsPlayerAdmin(playerid) != 0)
- {
- format(playertext,sizeof(playertext), "4** [%i] %s: %s",playerid,PlayerName(playerid),text);
- IRC_Say(EchoConnection, EchoChan, playertext);
- return true;
- }
- else
- {
- format(playertext,sizeof(playertext), "2** 4[%i]2 %s: %s",playerid,PlayerName(playerid),text);
- IRC_Say(EchoConnection, EchoChan, playertext);
- return true;
- }
- }
- 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:
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- if (GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
- {
- reasonMsg = "Drive By (MAC-10)";
- }
- else
- {
- reasonMsg = "MAC-10";
- }
- }
- else
- {
- reasonMsg = "MAC-10";
- }
- }
- case 29:
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- if (GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
- {
- reasonMsg = "Drive By (MP5)";
- }
- else
- {
- reasonMsg = "MP5";
- }
- }
- else
- {
- reasonMsg = "MP5";
- }
- }
- case 30:
- {
- reasonMsg = "AK-47";
- }
- case 31:
- {
- if (GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
- {
- switch (GetVehicleModel(GetPlayerVehicleID(killerid)))
- {
- case 447:
- {
- reasonMsg = "Sea Sparrow Machine Gun";
- }
- default:
- {
- reasonMsg = "M4";
- }
- }
- }
- else
- {
- reasonMsg = "M4";
- }
- }
- case 32:
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- if (GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
- {
- reasonMsg = "Drive By (TEC-9)";
- }
- else
- {
- reasonMsg = "TEC-9";
- }
- }
- else
- {
- reasonMsg = "TEC-9";
- }
- }
- case 33:
- {
- reasonMsg = "Rifle";
- }
- case 34:
- {
- reasonMsg = "Sniper Rifle";
- }
- case 37:
- {
- reasonMsg = "Fire";
- }
- case 38:
- {
- if (GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
- {
- switch(GetVehicleModel(GetPlayerVehicleID(killerid)))
- {
- 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 (GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
- {
- switch(GetVehicleModel(GetPlayerVehicleID(killerid)))
- {
- 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 (GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
- {
- switch(GetVehicleModel(GetPlayerVehicleID(killerid)))
- {
- case 425:
- {
- reasonMsg = "Hunter Rockets";
- }
- case 432:
- {
- reasonMsg = "Rhino Turret";
- }
- case 520:
- {
- reasonMsg = "Hydra Rockets";
- }
- default:
- {
- reasonMsg = "Explosion";
- }
- }
- }
- else
- {
- reasonMsg = "Explosion";
- }
- }
- default:
- {
- reasonMsg = "Unknown";
- }
- }
- format(msg, sizeof(msg), "14*** %s killed %s. (%s)", killerName, playerName, reasonMsg);
- }
- else
- {
- switch (reason)
- {
- case 53:
- {
- format(msg, sizeof(msg), "05*** %s died. (Drowned)", playerName);
- }
- case 54:
- {
- format(msg, sizeof(msg), "06*** %s died. (Collision)", playerName);
- }
- default:
- {
- format(msg, sizeof(msg), "08*** %s died.", playerName);
- }
- }
- }
- IRC_Say(EchoConnection, EchoChan, msg);
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement