Advertisement
Guest User

Untitled

a guest
Mar 10th, 2010
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 31.72 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //                                                                            //
  3. //                  IRC Administrator Basic 1.0 by PlayerX                    //
  4. //                                                                            //
  5. //          Available commands:                                               //
  6. //          - For ALL                                                         //
  7. //          !say <Message> o !msg <Message>                                   //
  8. //          !pm <PlayerName/PlayerID> <Message>                               //
  9. //          !players                                                          //
  10. //          !getid <PartOfName>                                               //
  11. //          - For Op (Operator)                                               //
  12. //          !kick <PlayerName/PlayerID> <Reason[optional]>                    //
  13. //          !ban <PlayerName/PlayerID> <Reason[Optional]>                     //
  14. //          !slap <PlayerName/PlayerID> <Reason[Optional]>                    //
  15. //          !kill <PlayerName/PlayerID> <Reason[Optional]>                    //
  16. //                                                                            //
  17. ////////////////////////////////////////////////////////////////////////////////
  18.  
  19. new IrcServer[40] = "irc.gtanet.com";
  20. new IrcPort = 6667;
  21. #define EchoChan "#changeme"
  22. #define Echochan "#changeme"
  23. #define OP_CHAN "@#changeme"
  24. new BotName[40] = "changeme";
  25. #define NSpassword "changeme"
  26.  
  27. #include <a_samp>
  28. #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
  29. #define green 0x33AA33AA
  30. #define red 0xAA3333AA
  31. #define orange 0xFF8040FF
  32.  
  33. native IRC_Connect(const server[], port, const nickname[], const realname[], const username[]);
  34. native IRC_Quit(botid, const message[] = "");
  35. native IRC_JoinChannel(botid, const channel[], const key[] = "");
  36. native IRC_PartChannel(botid, const channel[], const message[] = "");
  37. native IRC_ChangeNick(botid, const nick[]);
  38. native IRC_SetMode(botid, const target[], const mode[]);
  39. native IRC_Say(botid, const target[], const message[]);
  40. native IRC_Notice(botid, const target[], const message[]);
  41. native IRC_IsUserOnChannel(botid, const channel[], const user[]);
  42. native IRC_InviteUser(botid, const channel[], const user[]);
  43. native IRC_KickUser(botid, const channel[], const user[], const message[] = "");
  44. native IRC_GetUserChannelMode(botid, const channel[], const user[], dest[]);
  45. native IRC_GetChannelUserList(botid, const channel[], dest[], maxlength = sizeof dest);
  46. native IRC_SetChannelTopic(botid, const channel[], const topic[]);
  47. native IRC_SendRaw(botid, const message[]);
  48. native IRC_CreateGroup();
  49. native IRC_DestroyGroup(groupid);
  50. native IRC_AddToGroup(groupid, botid);
  51. native IRC_RemoveFromGroup(groupid, botid);
  52. native IRC_GroupSay(groupid, const target[], const message[]);
  53. native IRC_GroupNotice(groupid, const target[], const message[]);
  54.  
  55. // Callbacks
  56.  
  57. forward IRC_OnConnect(botid);
  58. forward IRC_OnDisconnect(botid);
  59. forward IRC_OnJoinChannel(botid, channel[]);
  60. forward IRC_OnLeaveChannel(botid, channel[], message[]);
  61. forward IRC_OnUserDisconnect(botid, user[], host[], message[]);
  62. forward IRC_OnUserJoinChannel(botid, channel[], user[], host[]);
  63. forward IRC_OnUserLeaveChannel(botid, channel[], user[], host[], message[]);
  64. forward IRC_OnUserNickChange(botid, oldnick[], newnick[], host[]);
  65. forward IRC_OnUserSetChannelMode(botid, channel[], user[], host[], mode[]);
  66. forward IRC_OnUserSetChannelTopic(botid, channel[], user[], host[], topic[]);
  67. forward IRC_OnUserSay(botid, recipient[], user[], host[], message[]);
  68. forward IRC_OnUserNotice(botid, recipient[], user[], host[], message[]);
  69. forward IRC_OnReceiveRaw(botid, message[]);
  70.  
  71. new EchoConnection;
  72. new Delay = 5000;
  73. forward IrcConnect();
  74. forward IrcLoggin();
  75.  
  76. new aDisconnectNames[][20] = {
  77.     {"7Timeout2"},
  78.     {"3Leaving2"},
  79.     {"4Kicked/Banned2"}
  80. };
  81.  
  82. public OnFilterScriptInit()
  83. {
  84.     EchoConnection = IRC_Connect(IrcServer, IrcPort, BotName, "IAdministrator Basic 1.0", "IABot");
  85.     return true;
  86. }
  87.  
  88. public IrcConnect()
  89. {
  90.     return 1;
  91. }
  92.  
  93. public OnFilterScriptExit()
  94. {
  95.     IRC_Quit(EchoConnection, "12* Bot Disconnected,cya");
  96.     return true;
  97. }
  98.  
  99. public IRC_OnConnect(botid)
  100. {
  101.     SetTimer("IrcLoggin", 3000, 1);
  102.     IRC_JoinChannel(EchoConnection, EchoChan);
  103.     return 1;
  104. }
  105.  
  106. public IRC_OnDisconnect(botid)
  107. {
  108.     SetTimer("IrcConnect", Delay,1);
  109.     return 1;
  110. }
  111.  
  112. public IrcLoggin()
  113. {
  114.     new msg[100];
  115.     format(msg, sizeof(msg), "ns identify %s", NSpassword);
  116.     IRC_SendRaw(EchoConnection, msg);
  117.     return 1;
  118. }
  119.  
  120. public IRC_OnJoinChannel(botid, channel[])
  121. {
  122.     if(strcmp(channel, EchoChan, true) == 0)
  123.     {
  124.         new msg[100], msg1[100];
  125.         GetServerVarAsString("hostname", msg1, sizeof(msg1));
  126.         format(msg, sizeof(msg), "3*** %s has connected to %s", BotName, msg1);
  127.         IRC_Say(EchoConnection, EchoChan, msg);
  128.     }
  129.     return 1;
  130. }
  131.  
  132. public IRC_OnLeaveChannel(botid, channel[], message[])
  133. {
  134.     if(strcmp(channel, EchoChan, true) == 0)
  135.     {
  136.         IRC_JoinChannel(EchoConnection,EchoChan);
  137.     }
  138.     return 1;
  139. }
  140.  
  141. public IRC_OnUserSay(botid, recipient[], user[], host[], message[])
  142. {
  143.     if ((message[0] != '!')) return true;
  144.     new space = (strfind(message, " "));
  145.     new cmdlen;
  146.     if (space>=1)
  147.     {
  148.         new lenmsg = strlen(message);
  149.         cmdlen = ((lenmsg-(lenmsg-space))-1);
  150.     }
  151.     else
  152.     {
  153.         cmdlen = (strlen(message)-1);
  154.     }
  155.     if (cmdlen == 2)
  156.     {
  157.         irccmd(pm,2,botid,recipient,user,message);
  158.     }
  159.     if (cmdlen == 3)
  160.     {
  161.         irccmd(say,3,botid,recipient,user,message);
  162.         irccmd(msg,3,botid,recipient,user,message);
  163.         irccmd(ban,3,botid,recipient,user,message);
  164.     }
  165.     if (cmdlen == 4)
  166.     {
  167.         irccmd(kick,4,botid,recipient,user,message);
  168.         irccmd(slap,4,botid,recipient,user,message);
  169.         irccmd(kill,4,botid,recipient,user,message);
  170.         irccmd(cmds,4,botid,recipient,user,message);
  171.     }
  172.     if (cmdlen == 5)
  173.     {
  174.         irccmd(getid,5,botid,recipient,user,message);
  175.     }
  176.  
  177.     if (cmdlen == 6)
  178.     {
  179.         irccmd(disarm,6,botid,recipient,user,message);
  180.     }
  181.  
  182.     if (cmdlen == 7)
  183.     {
  184.         irccmd(players,7,botid,recipient,user,message);
  185.         irccmd(setname,7,botid,recipient,user,message);
  186.         irccmd(explode,7,botid,recipient,user,message);
  187.     }
  188.  
  189.     if(cmdlen == 9)
  190.     {
  191.         irccmd(givemoney,9,botid,recipient,user,message);
  192.         irccmd(sethealth,9,botid,recipient,user,message);
  193.     }
  194.  
  195.     if(cmdlen == 10)
  196.     {
  197.         irccmd(giveweapon,10,botid,recipient,user,message);
  198.     }
  199.     return true;
  200. }
  201.  
  202. #define IRC_OPcmds  "!kick !ban !slap !kill !sethealth !explode !setname !disarm !giveweapon !givemoney"
  203. #define IRC_REGcmds "!say !pm !players !getid !cmds"
  204.  
  205. irccmd_cmds(conn, channel[], user[], params[])
  206. {
  207.     #pragma unused params
  208.     new string[128];
  209.  
  210.     if(IsPlayerOp(conn,channel,user))
  211.     {
  212.         format(string, sizeof(string), "1%s", IRC_OPcmds);
  213.         IRC_Say(EchoConnection, OP_CHAN, string);
  214.         format(string, sizeof(string), "1%s", IRC_REGcmds);
  215.         IRC_Say(EchoConnection, OP_CHAN, string);
  216.     }
  217.     else
  218.     {
  219.         format(string, sizeof(string), "1%s", IRC_REGcmds);
  220.         IRC_Say(EchoConnection, EchoChan, string);
  221.     }
  222.     return 1;
  223. }
  224.  
  225. irccmd_pm(conn, channel[], user[], params[])
  226. {
  227.     new giveid,msg[256],lolz1[256], lolz2[256], pon[100];
  228.     if(sscanf(params,"ss",pon,msg)) return IRC_Say(EchoConnection, EchoChan,"3Usage: !pm <PartOfName/PlayerID> <Message>");
  229.     giveid = ReturnUser(pon);
  230.     if(!IsPlayerConnected(giveid))return IRC_Say(EchoConnection, EchoChan,"4*** Error: Invalid player ID.");
  231.     format(lolz1,256, "*** Pm from %s (IRC): %s",user, msg);
  232.     format(lolz2,256, "5*** Pm to %s (ID:%d): %s",PlayerName(giveid),giveid,msg);
  233.     SendClientMessage(giveid,green,lolz1);
  234.     IRC_Say(EchoConnection, EchoChan, lolz2);
  235.     #pragma unused conn, channel
  236.     return true;
  237. }
  238. irccmd_say(conn, channel[], user[], params[])
  239. {
  240.     if(!strlen(params)) return IRC_Say(EchoConnection,channel,"3Usage: !say <Message>");
  241.     new lolz1[256], lolz2[256];
  242.     if(IsPlayerOwner(conn,channel,user))
  243.     {
  244.         format(lolz1,256,"* Admin %s on irc: %s",user,params);
  245.         SendClientMessageToAll(orange, lolz1);
  246.         format(lolz2,256,"2* Admin %s on irc: %s",user,params);
  247.         IRC_Say(EchoConnection,channel,lolz2);
  248.         return true;
  249.     }
  250.     else if(IsPlayerSop(conn,channel,user))
  251.     {
  252.         format(lolz1,256,"* Admin %s on irc: %s",user,params);
  253.         SendClientMessageToAll(orange, lolz1);
  254.         format(lolz2,256,"2* Admin %s on irc: %s",user,params);
  255.         IRC_Say(EchoConnection,channel,lolz2);
  256.         return true;
  257.     }
  258.     else if(IsPlayerOp(conn,channel,user))
  259.     {
  260.         format(lolz1,256,"* Admin %s on irc: %s",user,params);
  261.         SendClientMessageToAll(orange, lolz1);
  262.         format(lolz2,256,"2* Admin %s on irc: %s",user,params);
  263.         IRC_Say(EchoConnection,channel,lolz2);
  264.         return true;
  265.     }
  266.     else if(IsPlayerHop(conn,channel,user))
  267.     {
  268.         format(lolz1,256,"* Mod %s on irc: %s",user,params);
  269.         SendClientMessageToAll(orange, lolz1);
  270.         format(lolz2,256,"2* Mod %s on irc: %s",user,params);
  271.         IRC_Say(EchoConnection,channel,lolz2);
  272.         return true;
  273.     }
  274.     else if(IsPlayerVoi(conn,channel,user))
  275.     {
  276.         format(lolz1,256,"* Guest %s on irc: %s",user,params);
  277.         SendClientMessageToAll(orange, lolz1);
  278.         format(lolz2,256,"2* Guest %s on irc: %s",user,params);
  279.         IRC_Say(EchoConnection,channel,lolz2);
  280.         return true;
  281.     }
  282.     format(lolz1,256,"* Guest %s on irc: %s",user,params);
  283.     SendClientMessageToAll(orange, lolz1);
  284.     format(lolz2,256,"2* Guest %s on irc: %s",user,params);
  285.     IRC_Say(EchoConnection,channel,lolz2);
  286.     #pragma unused conn
  287.     return true;
  288. }
  289. irccmd_msg(conn, channel[], user[], params[])
  290. {
  291.     if(!strlen(params)) return IRC_Say(EchoConnection,channel,"3Usage: !msg <Message>");
  292.     new lolz1[256], lolz2[256];
  293.     if(IsPlayerOwner(conn,channel,user))
  294.     {
  295.         format(lolz1,256,"* Admin %s on irc: %s",user,params);
  296.         SendClientMessageToAll(orange, lolz1);
  297.         format(lolz2,256,"2* Admin %s on irc: %s",user,params);
  298.         IRC_Say(EchoConnection,channel,lolz2);
  299.         return true;
  300.     }
  301.     else if(IsPlayerSop(conn,channel,user))
  302.     {
  303.         format(lolz1,256,"* Admin %s on irc: %s",user,params);
  304.         SendClientMessageToAll(orange, lolz1);
  305.         format(lolz2,256,"2* Admin %s on irc: %s",user,params);
  306.         IRC_Say(EchoConnection,channel,lolz2);
  307.         return true;
  308.     }
  309.     else if(IsPlayerOp(conn,channel,user))
  310.     {
  311.         format(lolz1,256,"* Admin %s on irc: %s",user,params);
  312.         SendClientMessageToAll(orange, lolz1);
  313.         format(lolz2,256,"2* Admin %s on irc: %s",user,params);
  314.         IRC_Say(EchoConnection,channel,lolz2);
  315.         return true;
  316.     }
  317.     else if(IsPlayerHop(conn,channel,user))
  318.     {
  319.         format(lolz1,256,"* Mod %s on irc: %s",user,params);
  320.         SendClientMessageToAll(orange, lolz1);
  321.         format(lolz2,256,"2* Mod %s on irc: %s",user,params);
  322.         IRC_Say(EchoConnection,channel,lolz2);
  323.         return true;
  324.     }
  325.     else if(IsPlayerVoi(conn,channel,user))
  326.     {
  327.         format(lolz1,256,"* Guest %s on irc: %s",user,params);
  328.         SendClientMessageToAll(orange, lolz1);
  329.         format(lolz2,256,"2* Guest %s on irc: %s",user,params);
  330.         IRC_Say(EchoConnection,channel,lolz2);
  331.         return true;
  332.     }
  333.     format(lolz1,256,"* Guest %s on irc: %s",user,params);
  334.     SendClientMessageToAll(orange, lolz1);
  335.     format(lolz2,256,"2* Guest %s on irc: %s",user,params);
  336.     IRC_Say(EchoConnection,channel,lolz2);
  337.     #pragma unused conn
  338.     return true;
  339. }
  340.  
  341. irccmd_ban(conn, channel[], user[], params[])
  342. {
  343.     new giveid,msg[255],sayban[255], bansay[256], pon[100];
  344.     if(!IsPlayerOp(conn,channel,user)) return AccessDenied(user);
  345.     if(sscanf(params, "sz",pon,msg)) return IRC_Say(EchoConnection,channel,"3Usage: !ban <PartOfName/PlayerID> <Reason [Optional]>");
  346.     giveid = ReturnUser(pon);
  347.     if(!IsPlayerConnected(giveid)) return IRC_Say(EchoConnection,channel,"4*** Error: Invalid Player ID");
  348.     format(sayban,sizeof(sayban),"*** Admin %s (IRC) banned player %s (ID:%d), Reason: %s.",user,PlayerName(giveid),giveid,msg[0] ? msg: "None");
  349.     format(bansay,sizeof(bansay),"4*** Admin %s (IRC) banned player %s (ID:%d), Reason: %s.",user,PlayerName(giveid),giveid,msg[0] ? msg: "None");
  350.     SendClientMessageToAll(red,sayban);
  351.     IRC_Say(EchoConnection,channel,bansay);
  352.     BanEx(giveid,msg);
  353.     #pragma unused conn
  354.     return true;
  355. }
  356.  
  357. irccmd_kick(conn, channel[], user[], params[])
  358. {
  359.     new giveid,msg[255],saykick[255],kicksay[256],pon[100];
  360.     if(!IsPlayerOp(conn,channel,user)) return AccessDenied(user);
  361.     if(sscanf(params, "sz", pon,msg)) return IRC_Say(EchoConnection,channel,"3Usage: !kick <PartOfName/PlayerID> <Reason [Optional]>");
  362.     giveid = ReturnUser(pon);
  363.     if(!IsPlayerConnected(giveid)) return IRC_Say(EchoConnection,channel,"4*** Error: Invalid Player ID");
  364.     format(saykick,sizeof(saykick),"*** Admin %s (IRC) kicked player %s (ID:%d), Reason: %s.",user,PlayerName(giveid),giveid,msg[0] ? msg: "None");
  365.     format(kicksay,sizeof(kicksay),"4*** Admin %s (IRC) kicked player %s (ID:%d), Reason: %s.",user,PlayerName(giveid),giveid,msg[0] ? msg: "None");
  366.     SendClientMessageToAll(red,saykick);
  367.     IRC_Say(EchoConnection,channel,kicksay);
  368.     Kick(giveid);
  369.     #pragma unused conn
  370.     return true;
  371. }
  372.  
  373. irccmd_kill(conn, channel[], user[], params[])
  374. {
  375.     new giveid,msg[255],lolz1[255],lolz2[256],pon[100];
  376.     if(!IsPlayerHop(conn,channel,user)) return AccessDenied(user);
  377.     if(sscanf(params,"sz",pon,msg)) return IRC_Say(EchoConnection,channel,"3Usage: !kill <PartOfName/PlayerID> <Reason [Optional]>");
  378.     giveid = ReturnUser(pon);
  379.     if(!IsPlayerConnected(giveid)) return IRC_Say(EchoConnection,channel,"4*** Error: Invalid Player ID");
  380.     SetPlayerHealth(giveid,0);
  381.     SetPlayerArmour(giveid,0);
  382.     format(lolz1,sizeof(lolz1),"*** Admin %s (IRC) killed player %s (ID:%d), Reason: %s.",user,PlayerName(giveid),giveid,msg[0] ? msg: "None");
  383.     format(lolz2,sizeof(lolz2),"4*** Admin %s (IRC) killed player %s (ID:%d), Reason: %s.",user,PlayerName(giveid),giveid,msg[0] ? msg: "None");
  384.     SendClientMessageToAll(red,lolz1);
  385.     IRC_Say(EchoConnection,channel,lolz2);
  386.     #pragma unused conn
  387.     return true;
  388. }
  389.  
  390. irccmd_slap(conn, channel[], user[], params[])
  391. {
  392.     new giveid,lolz1[256],lolz2[256],msg[256],pon[100];
  393.     if(!IsPlayerHop(conn,channel,user)) return AccessDenied(user);
  394.     if(sscanf(params,"sz",pon,msg)) return IRC_Say(EchoConnection,channel,"3Usage: !slap <PartOfName/PlayerID> <Reason [Optional]>");
  395.     giveid = ReturnUser(pon);
  396.     if(!IsPlayerConnected(giveid))return IRC_Say(EchoConnection,channel,"4*** Error: Invalid player ID.");
  397.     new Float:slx, Float:sly, Float:slz;
  398.     new Float:shealth;
  399.     GetPlayerHealth(giveid, shealth);
  400.     SetPlayerHealth(giveid, shealth-15);
  401.     GetPlayerPos(giveid, slx, sly, slz);
  402.     SetPlayerPos(giveid, slx+5, sly, slz);
  403.     format(lolz1,256,"4*** Admin %s (IRC) slaps player %s (ID:%d), Reason: %s.",user,PlayerName(giveid),giveid,msg[0] ? msg: "None");
  404.     format(lolz2,256,"*** Admin %s (IRC) slaps player %s (ID:%d), Reason: %s.",user,PlayerName(giveid),giveid,msg[0] ? msg: "None");
  405.     IRC_Say(EchoConnection,channel,lolz1);
  406.     SendClientMessageToAll(red,lolz2);
  407.     #pragma unused conn
  408.     return true;
  409. }
  410.  
  411. irccmd_getid(conn,  channel[], user[], params[])
  412. {
  413.     new GetPlayer[256],giveid,lolz1[256],lolz2[256];
  414.     if(sscanf(params,"s",GetPlayer)) return IRC_Say(EchoConnection,channel,"3Usage: !getid <PartOfName>");
  415.     for (giveid=0; giveid<=MAX_PLAYERS; giveid++)
  416.     {
  417.         if (IsPlayerConnected(giveid))
  418.         {
  419.             GetPlayerName(giveid,GetPlayer,16);
  420.             new space = (strfind(GetPlayer, params));
  421.             if (space != -1)
  422.             {
  423.                 format(lolz1, sizeof(lolz1), "3*** Player whose name is %s has the ID: %d", GetPlayer, giveid);
  424.                 IRC_Say(EchoConnection,channel,lolz1);
  425.                 return true;
  426.             }
  427.         }
  428.     }
  429.     format(lolz2, sizeof(lolz2),"4*** Error: Invalid Name", params[0]);
  430.     IRC_Say(EchoConnection,channel,lolz2);
  431.     #pragma unused conn,user
  432.     return true;
  433. }
  434.  
  435. irccmd_players(conn, channel[], user[], params[])
  436. {
  437.     new count1;
  438.     new PlayerNames[512];
  439.     new msg[512];
  440.     for(new i=0; i<=MAX_PLAYERS; i++)
  441.     {
  442.         if(IsPlayerConnected(i))
  443.         {
  444.             if(count1 == 0)
  445.             {
  446.                 new PlayerName1[MAX_PLAYER_NAME];
  447.                 GetPlayerName(i, PlayerName1, sizeof(PlayerName1));
  448.                 format(PlayerNames, sizeof(PlayerNames),"[%d] %s",i,PlayerName1);
  449.                 count1++;
  450.             }
  451.             else
  452.             {
  453.                 new PlayerName1[MAX_PLAYER_NAME];
  454.                 GetPlayerName(i, PlayerName1, sizeof(PlayerName1));
  455.                 format(PlayerNames, sizeof(PlayerNames),"%s, [%d] %s",PlayerNames,i,PlayerName1);
  456.                 count1++;
  457.             }
  458.         }
  459.         else { if(count1 == 0) format(PlayerNames, sizeof(PlayerNames),"No Players Online"); }
  460.     }
  461.     new counter1 = 0;
  462.     new players = GetMaxPlayers();
  463.     for(new i=0; i<=MAX_PLAYERS; i++)
  464.     {
  465.         if(IsPlayerConnected(i)) counter1++;
  466.     }
  467.     format(msg,512,"3*** Players Online [%d/%d]: %s",counter1,players,PlayerNames);
  468.     IRC_Say(EchoConnection,channel,msg);
  469.     #pragma unused params,user,conn
  470.     return true;
  471. }
  472.  
  473. irccmd_giveweapon(conn, channel[], user[], params[])
  474. {
  475.     new string[128],
  476.         ID,
  477.         weapid,
  478.         ammo;
  479.  
  480.     if(sscanf(params, "iii", ID, weapid, ammo))
  481.         return IRC_Say(EchoConnection, EchoChan, "Use: !giveweapon [ID] [WEPID] [AMMO]");
  482.     if(!IsPlayerOp(conn,channel,user))
  483.         return AccessDenied(user);
  484.     if(!IsPlayerConnected(ID))
  485.         return IRC_Say(EchoConnection, EchoChan,"4*** Error: Invalid player ID.");
  486.  
  487.     GivePlayerWeapon(ID, weapid, ammo);
  488.  
  489.     new oname[MAX_PLAYER_NAME];
  490.     GetPlayerName(ID, oname, sizeof(oname));
  491.  
  492.     new weapname[24];
  493.     GetWeaponName(weapid, weapname, 32);
  494.  
  495.     format(string, sizeof(string), "%s has been given a %d with %d ammo by IRC admin %s", oname, weapname, ammo, user);
  496.  
  497.     SendClientMessageToAll(red, string);
  498.     IRC_Say(EchoConnection,channel,string);
  499.     return 1;
  500. }
  501.  
  502. irccmd_givemoney(conn, channel[], user[], params[])
  503. {
  504.     new string[128],
  505.         ID,
  506.         amount;
  507.  
  508.     if(sscanf(params, "ii", ID, amount))
  509.         return IRC_Say(EchoConnection, EchoChan, "Use: !givemoney [ID] [AMMOUNT]");
  510.  
  511.     if(!IsPlayerOp(conn,channel,user))
  512.         return AccessDenied(user);
  513.     if(!IsPlayerConnected(ID))
  514.         return IRC_Say(EchoConnection, EchoChan,"4*** Error: Invalid player ID.");
  515.  
  516.     GivePlayerMoney(ID, amount);
  517.  
  518.     new oname[MAX_PLAYER_NAME];
  519.     GetPlayerName(ID, oname, sizeof(oname));
  520.  
  521.     format(string, sizeof(string), "\"%s\" has been given $%d by IRC admin \"%s\"", oname, amount, user);
  522.  
  523.     SendClientMessageToAll(red, string);
  524.     IRC_Say(EchoConnection,channel,string);
  525.     return 1;
  526. }
  527. irccmd_setname(conn, channel[], user[], params[])
  528. {
  529.     new string[128],
  530.         ID,
  531.         newname[32];
  532.  
  533.     if(sscanf(params, "is", ID, newname))
  534.         return IRC_Say(EchoConnection, EchoChan, "Use: !setname [ID] [NAME]");
  535.     if(!IsPlayerOp(conn,channel,user))
  536.         return AccessDenied(user);
  537.     if(!IsPlayerConnected(ID))
  538.         return IRC_Say(EchoConnection, EchoChan,"4*** Error: Invalid player ID.");
  539.  
  540.     new oname[MAX_PLAYER_NAME];
  541.     GetPlayerName(ID, oname, sizeof(oname));
  542.  
  543.     format(string, sizeof(string), "%s has had his name set to %s by IRC admin %s", oname, newname, user);
  544.  
  545.     SetPlayerName(ID, newname);
  546.  
  547.     SendClientMessageToAll(red, string);
  548.     IRC_Say(EchoConnection,channel,string);
  549.     return 1;
  550. }
  551.  
  552.  
  553. irccmd_sethealth(conn, channel[], user[], params[])
  554. {
  555.     new string[128],
  556.         ID,
  557.         health;
  558.  
  559.     if(sscanf(params, "is", ID, health))
  560.         return IRC_Say(EchoConnection, EchoChan, "Use: !sethealth [ID] [HEALTH]");
  561.     if(!IsPlayerOp(conn,channel,user))
  562.         return AccessDenied(user);
  563.     if(!IsPlayerConnected(ID))
  564.         return IRC_Say(EchoConnection, EchoChan,"4*** Error: Invalid player ID.");
  565.  
  566.     SetPlayerHealth(ID, health);
  567.  
  568.     new oname[MAX_PLAYER_NAME];
  569.     GetPlayerName(ID, oname, sizeof(oname));
  570.  
  571.     format(string, sizeof(string), "%s has had thier health set to %.0f by IRC admin %s", oname, health, user);
  572.  
  573.     SendClientMessageToAll(red, string);
  574.     IRC_Say(EchoConnection,channel,string);
  575.     return 1;
  576. }
  577.  
  578. irccmd_disarm(conn, channel[], user[], params[])
  579. {
  580.     new string[128],
  581.         ID;
  582.  
  583.     if(sscanf(params, "i", ID))
  584.         return IRC_Say(EchoConnection, EchoChan, "Use: !disarm [ID]");
  585.     if(!IsPlayerOp(conn,channel,user))
  586.         return AccessDenied(user);
  587.     if(!IsPlayerConnected(ID))
  588.         return IRC_Say(EchoConnection, EchoChan,"4*** Error: Invalid player ID.");
  589.  
  590.     ResetPlayerWeapons(ID);
  591.  
  592.     new oname[MAX_PLAYER_NAME];
  593.     GetPlayerName(ID, oname, sizeof(oname));
  594.  
  595.     format(string, sizeof(string), "%s has had their weapons reset by IRC admin %s", oname, user);
  596.  
  597.     SendClientMessageToAll(red, string);
  598.     IRC_Say(EchoConnection,channel,string);
  599.     return 1;
  600. }
  601.  
  602. irccmd_explode(conn, channel[], user[], params[])
  603. {
  604.     new string[128],
  605.         ID;
  606.  
  607.     if(sscanf(params, "i", ID))
  608.         return IRC_Say(EchoConnection, EchoChan, "Use: !explode [ID]");
  609.     if(!IsPlayerOp(conn,channel,user))
  610.         return AccessDenied(user);
  611.     if(!IsPlayerConnected(ID))
  612.         return IRC_Say(EchoConnection, EchoChan,"4*** Error: Invalid player ID.");
  613.  
  614.     new Float:x, Float:y, Float:z;
  615.     GetPlayerPos(ID, x, y, z);
  616.     CreateExplosion(x, y, z, 10, 0);
  617.  
  618.     new oname[MAX_PLAYER_NAME];
  619.     GetPlayerName(ID, oname, sizeof(oname));
  620.  
  621.     format(string, sizeof(string), "%s has been exploded by IRC admin %s", oname, user);
  622.  
  623.     SendClientMessageToAll(red, string);
  624.     IRC_Say(EchoConnection,channel,string);
  625.     return 1;
  626. }
  627.  
  628.  
  629. stock sscanf(string[], format[], {Float,_}:...)
  630. {
  631.     new
  632.         formatPos = 0,
  633.         stringPos = 0,
  634.         paramPos = 2,
  635.         paramCount = numargs();
  636.     while (paramPos < paramCount && string[stringPos])
  637.     {
  638.         switch (format[formatPos++])
  639.         {
  640.             case '\0':
  641.             {
  642.                 return 0;
  643.             }
  644.             case 'i', 'd':
  645.             {
  646.                 new
  647.                     neg = 1,
  648.                     num = 0,
  649.                     ch = string[stringPos];
  650.                 if (ch == '-')
  651.                 {
  652.                     neg = -1;
  653.                     ch = string[++stringPos];
  654.                 }
  655.                 do
  656.                 {
  657.                     stringPos++;
  658.                     if (ch >= '0' && ch <= '9')
  659.                     {
  660.                         num = (num * 10) + (ch - '0');
  661.                     }
  662.                     else
  663.                     {
  664.                         return 1;
  665.                     }
  666.                 }
  667.                 while ((ch = string[stringPos]) && ch != ' ');
  668.                 setarg(paramPos, 0, num * neg);
  669.             }
  670.             case 'h', 'x':
  671.             {
  672.                 new
  673.                     ch,
  674.                     num = 0;
  675.                 while ((ch = string[stringPos++]))
  676.                 {
  677.                     switch (ch)
  678.                     {
  679.                         case 'x', 'X':
  680.                         {
  681.                             num = 0;
  682.                             continue;
  683.                         }
  684.                         case '0' .. '9':
  685.                         {
  686.                             num = (num << 4) | (ch - '0');
  687.                         }
  688.                         case 'a' .. 'f':
  689.                         {
  690.                             num = (num << 4) | (ch - ('a' - 10));
  691.                         }
  692.                         case 'A' .. 'F':
  693.                         {
  694.                             num = (num << 4) | (ch - ('A' - 10));
  695.                         }
  696.                         case ' ':
  697.                         {
  698.                             break;
  699.                         }
  700.                         default:
  701.                         {
  702.                             return 1;
  703.                         }
  704.                     }
  705.                 }
  706.                 setarg(paramPos, 0, num);
  707.             }
  708.             case 'c':
  709.             {
  710.                 setarg(paramPos, 0, string[stringPos++]);
  711.             }
  712.             case 'f':
  713.             {
  714.                 new tmp[25];
  715.                 strmid(tmp, string, stringPos, stringPos+sizeof(tmp)-2);
  716.                 setarg(paramPos, 0, _:floatstr(tmp));
  717.             }
  718.             case 's', 'z':
  719.             {
  720.                 new
  721.                     i = 0,
  722.                     ch;
  723.                 if (format[formatPos])
  724.                 {
  725.                     while ((ch = string[stringPos++]) && ch != ' ')
  726.                     {
  727.                         setarg(paramPos, i++, ch);
  728.                     }
  729.                     if (!i) return 1;
  730.                 }
  731.                 else
  732.                 {
  733.                     while ((ch = string[stringPos++]))
  734.                     {
  735.                         setarg(paramPos, i++, ch);
  736.                     }
  737.                 }
  738.                 stringPos--;
  739.                 setarg(paramPos, i, '\0');
  740.             }
  741.             default:
  742.             {
  743.                 continue;
  744.             }
  745.         }
  746.         while (string[stringPos] && string[stringPos] != ' ')
  747.         {
  748.             stringPos++;
  749.         }
  750.         while (string[stringPos] == ' ')
  751.         {
  752.             stringPos++;
  753.         }
  754.         paramPos++;
  755.     }
  756.     while (format[formatPos] == 'z') formatPos++;
  757.     return format[formatPos];
  758. }
  759.  
  760. IsNumeric(const string[])
  761. {
  762.     for (new i = 0, j = strlen(string); i < j; i++)
  763.     {
  764.         if (string[i] > '9' || string[i] < '0') return 0;
  765.     }
  766.     return 1;
  767. }
  768.  
  769. ReturnUser(text[])
  770. {
  771.     new pos = 0;
  772.     while (text[pos] < 0x21)
  773.     {
  774.         if (text[pos] == 0) return INVALID_PLAYER_ID;
  775.         pos++;
  776.     }
  777.     new userid = INVALID_PLAYER_ID;
  778.     if (IsNumeric(text[pos]))
  779.     {
  780.         userid = strval(text[pos]);
  781.         if (userid >=0 && userid < MAX_PLAYERS)
  782.         {
  783.             if(!IsPlayerConnected(userid))
  784.             {
  785.                 userid = INVALID_PLAYER_ID;
  786.             }
  787.             else
  788.             {
  789.                 return userid;
  790.             }
  791.         }
  792.     }
  793.     new giveid;
  794.     new GetPlayer[256];
  795.     for (giveid=0; giveid<=MAX_PLAYERS; giveid++)
  796.     {
  797.         if (IsPlayerConnected(giveid))
  798.         {
  799.             GetPlayerName(giveid,GetPlayer,16);
  800.             new space = (strfind(GetPlayer, text,true));
  801.             if (space != -1)
  802.             {
  803.                 return giveid;
  804.             }
  805.         }
  806.     }
  807.     return userid;
  808. }
  809.  
  810. forward AccessDenied(user[]);
  811. public AccessDenied(user[])
  812. {
  813.     new Denied[256];
  814.     format(Denied,sizeof(Denied),"Notice %s 4*** Error: You don't have the necessary level.",user);
  815.     IRC_Notice(EchoConnection,user,Denied);
  816.     return true;
  817. }
  818.  
  819. stock PlayerName(playerid)
  820. {
  821.     new name[255];
  822.     GetPlayerName(playerid, name, 255);
  823.     return name;
  824. }
  825.  
  826. stock IsPlayerVoi(conn,channel[],user[])
  827. {
  828.     new ircLevel[5];
  829.     IRC_GetUserChannelMode(conn, channel, user, ircLevel);
  830.     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;
  831.     return false;
  832. }
  833.  
  834. stock IsPlayerHop(conn,channel[],user[])
  835. {
  836.     new ircLevel[5];
  837.     IRC_GetUserChannelMode(conn, channel, user, ircLevel);
  838.     if(!strcmp(ircLevel, ".", true,1) || !strcmp(ircLevel, "~", true,1) || !strcmp(ircLevel, "&", true,1) || !strcmp(ircLevel, "@", true,1) || !strcmp(ircLevel, "%", true,1)) return true;
  839.     return false;
  840. }
  841.  
  842. stock IsPlayerOp(conn,channel[],user[])
  843. {
  844.     new ircLevel[5];
  845.     IRC_GetUserChannelMode(conn, channel, user, ircLevel);
  846.     if(!strcmp(ircLevel, ".", true,1) || !strcmp(ircLevel, "~", true,1) || !strcmp(ircLevel, "&", true,1) || !strcmp(ircLevel, "@", true,1)) return true;
  847.     return false;
  848. }
  849.  
  850. stock IsPlayerSop(conn, channel[], user[])
  851. {
  852.     new playerlevel[5];
  853.     IRC_GetUserChannelMode(conn, channel, user, playerlevel);
  854.     if(!strcmp(playerlevel, ".", true,1) || !strcmp(playerlevel, "~", true,1) || !strcmp(playerlevel, "&", true,1)) return true;
  855.     return false;
  856. }
  857.  
  858. stock IsPlayerOwner(conn, channel[], user[])
  859. {
  860.     new playerlevel[5];
  861.     IRC_GetUserChannelMode(conn, channel, user, playerlevel);
  862.     if(!strcmp(playerlevel, ".", true,1) || !strcmp(playerlevel, "~", true,1)) return true;
  863.     return false;
  864. }
  865.  
  866. public OnPlayerConnect(playerid)
  867. {
  868.     new JoinMsg1[128];
  869.     format(JoinMsg1,128, "6** 5[%i]3 %s has joined the server.", playerid, PlayerName(playerid));
  870.     IRC_Say(EchoConnection, EchoChan, JoinMsg1);
  871.     return true;
  872. }
  873.  
  874. public OnPlayerDisconnect(playerid, reason)
  875. {
  876.     new leaveMsg1[256];
  877.     format(leaveMsg1, 256, "6** 4[%i]2 %s has left the server. (%s)", playerid, PlayerName(playerid), aDisconnectNames[reason]);
  878.     IRC_Say(EchoConnection, EchoChan, leaveMsg1);
  879.     return true;
  880. }
  881.  
  882. public OnPlayerText(playerid, text[])
  883. {
  884.     new playertext[256];
  885.     if(IsPlayerAdmin(playerid) != 0)
  886.     {
  887.         format(playertext,sizeof(playertext), "4** [%i] %s: %s",playerid,PlayerName(playerid),text);
  888.         IRC_Say(EchoConnection, EchoChan, playertext);
  889.         return true;
  890.     }
  891.     else
  892.     {
  893.         format(playertext,sizeof(playertext), "2** 4[%i]2 %s: %s",playerid,PlayerName(playerid),text);
  894.         IRC_Say(EchoConnection, EchoChan, playertext);
  895.         return true;
  896.     }
  897. }
  898.  
  899. public OnPlayerDeath(playerid, killerid, reason)
  900. {
  901.     new
  902.         msg[128],
  903.         killerName[MAX_PLAYER_NAME],
  904.         reasonMsg[32],
  905.         playerName[MAX_PLAYER_NAME];
  906.     GetPlayerName(killerid, killerName, sizeof(killerName));
  907.     GetPlayerName(playerid, playerName, sizeof(playerName));
  908.     if (killerid != INVALID_PLAYER_ID)
  909.     {
  910.         switch (reason)
  911.         {
  912.             case 0:
  913.             {
  914.                 reasonMsg = "Unarmed";
  915.             }
  916.             case 1:
  917.             {
  918.                 reasonMsg = "Brass Knuckles";
  919.             }
  920.             case 2:
  921.             {
  922.                 reasonMsg = "Golf Club";
  923.             }
  924.             case 3:
  925.             {
  926.                 reasonMsg = "Night Stick";
  927.             }
  928.             case 4:
  929.             {
  930.                 reasonMsg = "Knife";
  931.             }
  932.             case 5:
  933.             {
  934.                 reasonMsg = "Baseball Bat";
  935.             }
  936.             case 6:
  937.             {
  938.                 reasonMsg = "Shovel";
  939.             }
  940.             case 7:
  941.             {
  942.                 reasonMsg = "Pool Cue";
  943.             }
  944.             case 8:
  945.             {
  946.                 reasonMsg = "Katana";
  947.             }
  948.             case 9:
  949.             {
  950.                 reasonMsg = "Chainsaw";
  951.             }
  952.             case 10:
  953.             {
  954.                 reasonMsg = "Dildo";
  955.             }
  956.             case 11:
  957.             {
  958.                 reasonMsg = "Dildo";
  959.             }
  960.             case 12:
  961.             {
  962.                 reasonMsg = "Vibrator";
  963.             }
  964.             case 13:
  965.             {
  966.                 reasonMsg = "Vibrator";
  967.             }
  968.             case 14:
  969.             {
  970.                 reasonMsg = "Flowers";
  971.             }
  972.             case 15:
  973.             {
  974.                 reasonMsg = "Cane";
  975.             }
  976.             case 22:
  977.             {
  978.                 reasonMsg = "Pistol";
  979.             }
  980.             case 23:
  981.             {
  982.                 reasonMsg = "Silenced Pistol";
  983.             }
  984.             case 24:
  985.             {
  986.                 reasonMsg = "Desert Eagle";
  987.             }
  988.             case 25:
  989.             {
  990.                 reasonMsg = "Shotgun";
  991.             }
  992.             case 26:
  993.             {
  994.                 reasonMsg = "Sawn-off Shotgun";
  995.             }
  996.             case 27:
  997.             {
  998.                 reasonMsg = "Combat Shotgun";
  999.             }
  1000.             case 28:
  1001.             {
  1002.                 if(IsPlayerInAnyVehicle(playerid))
  1003.                 {
  1004.                     if (GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
  1005.                     {
  1006.                         reasonMsg = "Drive By (MAC-10)";
  1007.                     }
  1008.                     else
  1009.                     {
  1010.                         reasonMsg = "MAC-10";
  1011.                     }
  1012.                 }
  1013.                 else
  1014.                 {
  1015.                     reasonMsg = "MAC-10";
  1016.                 }
  1017.             }
  1018.             case 29:
  1019.             {
  1020.                 if(IsPlayerInAnyVehicle(playerid))
  1021.                 {
  1022.                     if (GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
  1023.                     {
  1024.                         reasonMsg = "Drive By (MP5)";
  1025.                     }
  1026.                     else
  1027.                     {
  1028.                         reasonMsg = "MP5";
  1029.                     }
  1030.                 }
  1031.                 else
  1032.                 {
  1033.                     reasonMsg = "MP5";
  1034.                 }
  1035.             }
  1036.             case 30:
  1037.             {
  1038.                 reasonMsg = "AK-47";
  1039.             }
  1040.             case 31:
  1041.             {
  1042.                 if (GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
  1043.                 {
  1044.                     switch (GetVehicleModel(GetPlayerVehicleID(killerid)))
  1045.                     {
  1046.                         case 447:
  1047.                         {
  1048.                             reasonMsg = "Sea Sparrow Machine Gun";
  1049.                         }
  1050.                         default:
  1051.                         {
  1052.                             reasonMsg = "M4";
  1053.                         }
  1054.                     }
  1055.                 }
  1056.                 else
  1057.                 {
  1058.                     reasonMsg = "M4";
  1059.                 }
  1060.             }
  1061.             case 32:
  1062.             {
  1063.                 if(IsPlayerInAnyVehicle(playerid))
  1064.                 {
  1065.                     if (GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
  1066.                     {
  1067.                         reasonMsg = "Drive By (TEC-9)";
  1068.                     }
  1069.                     else
  1070.                     {
  1071.                         reasonMsg = "TEC-9";
  1072.                     }
  1073.                 }
  1074.                 else
  1075.                 {
  1076.                     reasonMsg = "TEC-9";
  1077.                 }
  1078.             }
  1079.             case 33:
  1080.             {
  1081.                 reasonMsg = "Rifle";
  1082.             }
  1083.             case 34:
  1084.             {
  1085.                 reasonMsg = "Sniper Rifle";
  1086.             }
  1087.             case 37:
  1088.             {
  1089.                 reasonMsg = "Fire";
  1090.             }
  1091.             case 38:
  1092.             {
  1093.                 if (GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
  1094.                 {
  1095.                     switch(GetVehicleModel(GetPlayerVehicleID(killerid)))
  1096.                     {
  1097.                         case 425:
  1098.                         {
  1099.                             reasonMsg = "Hunter Machine Gun";
  1100.                         }
  1101.                         default:
  1102.                         {
  1103.                             reasonMsg = "Minigun";
  1104.                         }
  1105.                     }
  1106.                 }
  1107.                 else
  1108.                 {
  1109.                     reasonMsg = "Minigun";
  1110.                 }
  1111.             }
  1112.             case 41:
  1113.             {
  1114.                 reasonMsg = "Spraycan";
  1115.             }
  1116.             case 42:
  1117.             {
  1118.                 reasonMsg = "Fire Extinguisher";
  1119.             }
  1120.             case 49:
  1121.             {
  1122.                 reasonMsg = "Vehicle Collision";
  1123.             }
  1124.             case 50:
  1125.             {
  1126.                 if (GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
  1127.                 {
  1128.                     switch(GetVehicleModel(GetPlayerVehicleID(killerid)))
  1129.                     {
  1130.                         case 417, 425, 447, 465, 469, 487, 488, 497, 501, 548, 563:
  1131.                         {
  1132.                             reasonMsg = "Helicopter Blades";
  1133.                         }
  1134.                         default:
  1135.                         {
  1136.                             reasonMsg = "Vehicle Collision";
  1137.                         }
  1138.                     }
  1139.                 }
  1140.                 else
  1141.                 {
  1142.                     reasonMsg = "Vehicle Collision";
  1143.                 }
  1144.             }
  1145.             case 51:
  1146.             {
  1147.                 if (GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
  1148.                 {
  1149.                     switch(GetVehicleModel(GetPlayerVehicleID(killerid)))
  1150.                     {
  1151.                         case 425:
  1152.                         {
  1153.                             reasonMsg = "Hunter Rockets";
  1154.                         }
  1155.                         case 432:
  1156.                         {
  1157.                             reasonMsg = "Rhino Turret";
  1158.                         }
  1159.                         case 520:
  1160.                         {
  1161.                             reasonMsg = "Hydra Rockets";
  1162.                         }
  1163.                         default:
  1164.                         {
  1165.                             reasonMsg = "Explosion";
  1166.                         }
  1167.                     }
  1168.                 }
  1169.                 else
  1170.                 {
  1171.                     reasonMsg = "Explosion";
  1172.                 }
  1173.             }
  1174.             default:
  1175.             {
  1176.                 reasonMsg = "Unknown";
  1177.             }
  1178.         }
  1179.         format(msg, sizeof(msg), "14*** %s killed %s. (%s)", killerName, playerName, reasonMsg);
  1180.     }
  1181.     else
  1182.     {
  1183.         switch (reason)
  1184.         {
  1185.             case 53:
  1186.             {
  1187.                 format(msg, sizeof(msg), "05*** %s died. (Drowned)", playerName);
  1188.             }
  1189.             case 54:
  1190.             {
  1191.                 format(msg, sizeof(msg), "06*** %s died. (Collision)", playerName);
  1192.             }
  1193.             default:
  1194.             {
  1195.                 format(msg, sizeof(msg), "08*** %s died.", playerName);
  1196.             }
  1197.         }
  1198.     }
  1199.     IRC_Say(EchoConnection, EchoChan, msg);
  1200.     return true;
  1201. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement