Advertisement
elrooT

rooT's Chatbot

Mar 4th, 2011
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 13.11 KB | None | 0 0
  1. /*==============================================================================
  2.             FS creado por rooT. para la comunidad Bristos-Server
  3.                             Espero que sea util!
  4.                            Gracias al Chaozman :D
  5. ==============================================================================*/
  6. #define FILTERSCRIPT
  7.  
  8. #define COLOR_RED           0xFF0000AA
  9. #define COLOR_LIGHTGREEN    0x38FF06FF
  10. #define LIGHTBLUE           0x0BBF6AA
  11. #define COLOR_WHITE         0xFFFFFFAA
  12.  
  13. #include <a_samp>
  14. #include <zcmd>
  15. #include <sscanf2>
  16. #pragma tabsize 0
  17.  
  18. //Chatbot
  19. new Botname[MAX_PLAYER_NAME] = "Chatbot! - by rooT!";
  20. new ServerName[128] = "Bristos-Server";
  21. new ServerURL[128] = "www.Foro-Bristos-Server.com";
  22. new Spam[MAX_PLAYERS] = 0;
  23. new BotMsg = 1;
  24. new BBot[MAX_PLAYERS] = 0;
  25. new bbid;
  26.  
  27. #define BotD 170
  28. #define BotD1 171
  29. #define BotD2 172
  30. #define BotD3 173
  31. #define BotD4 174
  32. #define BotD5 175
  33. #define BotD6 176
  34. #define BotD7 177
  35.  
  36. public OnFilterScriptInit()
  37. {
  38.     print("---------------------------------------");
  39.     print("----------Chat Bot - by rooT.----------");
  40.     print("---------------------------------------");
  41.     SetTimer("SendRandomMessage", 150000, true);
  42.     return 1;
  43. }
  44.  
  45. public OnFilterScriptExit()
  46. {
  47.     return 1;
  48. }
  49.  
  50. public OnPlayerConnect(playerid)
  51. {
  52.     SendConnectMessage(playerid);
  53.     return 0;
  54. }
  55.  
  56. public OnPlayerText(playerid, text[])
  57. {
  58.     new pname[MAX_PLAYER_NAME], string[128];
  59.     GetPlayerName(playerid, pname, sizeof(pname));
  60.     format(string, sizeof(string), "[%d]: %s", playerid, text);
  61.     SendPlayerMessageToAll(playerid, string);
  62.  
  63.     /*if(!strfind(text, "Hola", true) || !strfind(text, "hola", true))
  64.     {
  65.         if(BotMsg == 0) return 0;
  66.         if(Spam[playerid] == 1) return 0;
  67.         if(BBot[playerid] == 1) return 0;
  68.         new randommsg = random(5);
  69.         switch(randommsg)
  70.         {
  71.             case 0: format(string, sizeof(string), "Hola %s, bienvenido a Bristos-Server", Botname, pname);
  72.             case 1: format(string, sizeof(string), "Hey %s, no olvides visitar nuestro foro! www.Foro-Bristos-Server.com", Botname, pname);
  73.             case 2: format(string, sizeof(string), "MIREN QUIEN ENTRO AL SERVER :D! Que onda %s!", Botname, pname);
  74.             case 3: format(string, sizeof(string), "WAZZAAAAAAAAAAAAA! ", Botname);
  75.             case 4: format(string, sizeof(string), "%s dijo 'hola'... hehehe", Botname, pname);
  76.         }
  77.  
  78.         Spam[playerid] = 1;
  79.         SetTimerEx("NoSpam", 30000, false, "i", playerid);
  80.         SendBotMessage(string);
  81.         return 0;
  82.     }*/
  83.  
  84.     if(strfind(text, "!FAIL", true) > -1 || strfind(text, "!fail", true) > -1)
  85.     {
  86.         if(BotMsg == 0) return 0;
  87.         if(Spam[playerid] == 1) return 0;
  88.         if(BBot[playerid] == 1) return 0;
  89.         SendBotMessage("FAAAIL!");
  90.  
  91.         Spam[playerid] = 1;
  92.         SetTimerEx("NoSpam", 30000, false, "i", playerid);
  93.         return 0;
  94.     }
  95.    
  96.     if(strfind(text, "!foro", true) > -1 || strfind(text, "!foro", true) > -1)
  97.     {
  98.         if(BotMsg == 0) return 0;
  99.         if(Spam[playerid] == 1) return 0;
  100.         if(BBot[playerid] == 1) return 0;
  101.         GameTextForAll(ServerURL, 4000, 4);
  102.  
  103.         Spam[playerid] = 1;
  104.         SetTimerEx("NoSpam", 30000, false, "i", playerid);
  105.         return 0;
  106.     }
  107.  
  108.     if(strfind(text, "lol", true) > -1|| strfind(text, "LOL", true) > -1 || strfind(text, "rofl", true) > -1 || strfind(text, "lmao", true) > -1 || strfind(text, "lmfao", true) > -1)
  109.     {
  110.         if(BotMsg == 0) return 0;
  111.         if(Spam[playerid] == 1) return 0;
  112.         if(BBot[playerid] == 1) return 0;
  113.         SendBotMessage("Lot of Laughts! Fuck yeah.");
  114.  
  115.         Spam[playerid] = 1;
  116.         SetTimerEx("NoSpam", 30000, false, "i", playerid);
  117.         return 0;
  118.     }
  119.  
  120.     if(strfind(text, Botname, true) > -1 || strfind(text, Botname, true) > -1)
  121.     {
  122.         if(BotMsg == 0) return 0;
  123.         if(Spam[playerid] == 1) return 0;
  124.         if(BBot[playerid] == 1) return 0;
  125.         SendNameMessage(playerid);
  126.  
  127.         Spam[playerid] = 1;
  128.         SetTimerEx("NoSpam", 30000, false, "i", playerid);
  129.         return 0;
  130.     }
  131.     return 0;
  132. }
  133.  
  134. /*==============================================================================
  135. ================================================================================
  136. =============================Chatbot Commands!==================================
  137. ================================================================================
  138. ==============================================================================*/
  139.  
  140. CMD:cbot(playerid, params[])
  141. {
  142.     if(!IsPlayerAdmin(playerid))) return SendClientMessage(playerid, LIGHTBLUE, "Necesitas ser administrador para usar este Comando!");
  143.     if(isnull(params))
  144.     {
  145.         ShowPlayerDialog(playerid, BotD, DIALOG_STYLE_LIST, "Chatbot Configs", "Habilitar/Deshabilitar Chatbot\nBloquear Player\nDesbloquear Player\nEnviar mensaje\nCambiar Nombre (Chatbot)\nCambiar Server URL\nCambiar Server Name (Chatbot)", "Aceptar", "Cancelar");
  146.     }
  147.     return 1;
  148. }
  149.  
  150. //==============================================================================
  151. //==============================================================================
  152.  
  153. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  154. {
  155.     switch(dialogid)
  156.     {
  157.         case BotD:
  158.             if(response){
  159.                 switch(listitem){
  160.                     case 0: SwitchBot();
  161.                     case 1: ShowPlayerDialog(playerid, BotD1, DIALOG_STYLE_INPUT, Botname, "Bloquea un jugador", "Enviar", "Cancelar");
  162.                     case 2: ShowPlayerDialog(playerid, BotD2, DIALOG_STYLE_INPUT, Botname, "Desbloquea un jugador", "Enviar", "Cancelar");
  163.                     case 3: ShowPlayerDialog(playerid, BotD3, DIALOG_STYLE_INPUT, Botname, "Haz que el Chatbot hable", "Enviar", "Cancelar");
  164.                     case 4: ShowPlayerDialog(playerid, BotD4, DIALOG_STYLE_INPUT, Botname, "Cambia el nombre del bot", "Enviar", "Cancelar");
  165.                     case 5: ShowPlayerDialog(playerid, BotD7, DIALOG_STYLE_INPUT, Botname, "Cambia el nombre del Servidor", "Enviar", "Cancelar");
  166.                     case 6: ShowPlayerDialog(playerid, BotD6, DIALOG_STYLE_INPUT, Botname, "Cambia la URL del servidor", "Enviar", "Cancelar");
  167.                 }
  168.             }
  169.         case BotD1:
  170.             if(response){
  171.                 new str[128], name[MAX_PLAYER_NAME];
  172.                 if(sscanf(inputtext, "d", bbid))return ShowPlayerDialog(playerid, BotD1, DIALOG_STYLE_INPUT, Botname, "Bloquea un jugador", "Enviar", "Cancelar");
  173.                 if(!IsPlayerConnected(bbid))return SendClientMessage(playerid, COLOR_RED, "ERROR: El jugador no se encuentra conectado");
  174.                 GetPlayerName(bbid, name, MAX_PLAYER_NAME);
  175.                 if(BBot[bbid] == 0)
  176.                 {
  177.                     BBot[bbid] = 1;
  178.                     format(str, sizeof(str), "Ya no respondere al jugador %s (%d)", name, bbid);
  179.                     SendBotMessage(str);
  180.                 }
  181.                 else{
  182.                     format(str, 128, "El jugador %s(%i) ya esta bloqueado!", name, bbid);
  183.                     SendClientMessage(playerid, COLOR_RED, str);
  184.                 }
  185.             }
  186.         case BotD2:
  187.             if(response){
  188.                 new str[128], name[MAX_PLAYER_NAME];
  189.                 if(sscanf(inputtext, "d", bbid)) return ShowPlayerDialog(playerid, BotD2, DIALOG_STYLE_INPUT, Botname, "Desbloquea un jugador", "Enviar", "Cancelar");
  190.                 if(!IsPlayerConnected(bbid))return SendClientMessage(playerid, COLOR_RED, "ERROR: El jugador no se encuentra conectado");
  191.                 GetPlayerName(bbid, name, MAX_PLAYER_NAME);
  192.                 if(BBot[bbid] == 1)
  193.                 {
  194.                     BBot[bbid] = 0;
  195.                     format(str, sizeof(str), "Ahora le respondere al jugador %s (%d)", name, bbid);
  196.                     SendBotMessage(str);
  197.                 }
  198.                 else{
  199.                     format(str, 128, "El jugador %s(%i) no esta bloqueado!", name, bbid);
  200.                     SendClientMessage(playerid, LIGHTBLUE, str);
  201.                 }
  202.             }
  203.         case BotD3:
  204.             if(response){
  205.                 if(isnull(inputtext)) return ShowPlayerDialog(playerid, BotD3, DIALOG_STYLE_INPUT, Botname, "Haz que el Chatbot hable", "Enviar", "Cancelar");
  206.                 SendBotMessage(inputtext);
  207.             }
  208.         case BotD4:
  209.             if(response){
  210.                 if(isnull(inputtext)) return ShowPlayerDialog(playerid, BotD4, DIALOG_STYLE_INPUT, Botname, "Cambia el nombre del bot", "Enviar", "Cancelar");
  211.                 ChangeNameD(playerid, inputtext);
  212.             }
  213.         case BotD6:
  214.             if(response){
  215.                 if(isnull(inputtext)) return ShowPlayerDialog(playerid, BotD6, DIALOG_STYLE_INPUT, Botname, "Cambia la URL del servidor", "Enviar", "Cancelar");
  216.                 ChangeURL(playerid, inputtext);
  217.             }
  218.         case BotD7:
  219.             if(response){
  220.                 if(isnull(inputtext)) return ShowPlayerDialog(playerid, BotD7, DIALOG_STYLE_INPUT, Botname, "Cambia el nombre del Servidor", "Enviar", "Cancelar");
  221.                 ChangeSVN(playerid, inputtext);
  222.             }
  223.     }
  224.     return 1;
  225. }
  226.  
  227. //======================================================================Chatbot!
  228.  
  229. forward NoSpam(playerid);
  230. public NoSpam(playerid)
  231. {
  232.     new str[128];
  233.     format(str, sizeof(str), "Ya puedes hablar con %s", Botname);
  234.     SendClientMessage(playerid, COLOR_LIGHTGREEN, str);
  235.     Spam[playerid] = 0;
  236.     return 1;
  237. }
  238.  
  239. stock SwitchBot()
  240. {
  241.     new string[128];
  242.     if(BotMsg == 1)
  243.     {
  244.         BotMsg = 0;
  245.         format(string, sizeof(string), "No respondere a nadie mas");
  246.         SendBotMessage(string);
  247.     }
  248.     else if(BotMsg == 0)
  249.     {
  250.         BotMsg = 1;
  251.         format(string, sizeof(string), "Si me hablan les contestare :)");
  252.         SendBotMessage(string);
  253.     }
  254. }
  255.  
  256. stock SendBotMessage(txt[])
  257. {
  258.     new string[128];
  259.     format(string, sizeof(string), "|- %s: %s", Botname, txt);
  260.     SendClientMessageToAll(LIGHTBLUE, string);
  261. }
  262.  
  263. forward SendRandomMessage();
  264. public SendRandomMessage()
  265. {
  266.     new string[128];
  267.     new randommsg = random(7);
  268.     switch(randommsg)
  269.     {
  270.         case 0: format(string, sizeof(string), "|- %s: El que usa cheats se va a vivir una semana con el tio Lexotanil.", Botname);
  271.         case 1: format(string, sizeof(string), "|- %s: El que no visita %s se enfrentara a mi furia.", Botname, ServerURL);
  272.         case 2: format(string, sizeof(string), "|- %s: Si haces spam de otros servers, te agarra SlovaK y no nos hacemos cargo de nada.", Botname);
  273.         case 3: format(string, sizeof(string), "|- %s: NeedlesKane me maltrata :(", Botname);
  274.         case 4: format(string, sizeof(string), "|- %s: Dontdontdontdont!", Botname);
  275.         case 5: format(string, sizeof(string), "|- %s: heheeeeeeeeeeeeeeeeeeeeee waiiiiiiiiiiiii", Botname);
  276.         case 6: format(string, sizeof(string), "|- %s: Batimovil? WTF! %smovil rulez.", Botname, Botname);
  277.         case 7: format(string, sizeof(string), "|- %s: MrJacK me quiere cocinar, ayudaaaaa!", Botname);
  278.     }
  279.     SendClientMessageToAll(LIGHTBLUE, string);
  280.     return 1;
  281. }
  282.  
  283. forward SendNameMessage(playerid);
  284. public SendNameMessage(playerid)
  285. {
  286.     new string[128];
  287.     new pname[MAX_PLAYER_NAME];
  288.     GetPlayerName(playerid, pname, sizeof(pname));
  289.     new randommsg = random(7);
  290.     switch(randommsg)
  291.     {
  292.         case 0: format(string, sizeof(string), "|- %s: Quien le dio permiso a %s de decir mi nombre?", Botname, pname);
  293.         case 1: format(string, sizeof(string), "|- %s: Muerte a %s!", Botname, pname);
  294.         case 2: format(string, sizeof(string), "|- %s: Hola %s :D! Te deseo una muerte lenta.", Botname, pname);
  295.         case 3: format(string, sizeof(string), "|- %s: DEJEN DE HABLAR DE MI!", Botname);
  296.         case 4: format(string, sizeof(string), "|- %s: %s, que requieres?", Botname, pname);
  297.         case 5: format(string, sizeof(string), "|- %s: Arruinaste mi baƱo de esponja! Que quieres %s?", Botname, pname);
  298.         case 6: format(string, sizeof(string), "|- %s: Que %s te masajee los pies, es lo mejor.", Botname, pname);
  299.     }
  300.     SendClientMessageToAll(LIGHTBLUE, string);
  301.     return 1;
  302. }
  303.  
  304. stock SendConnectMessage(playerid)
  305. {
  306.     new string[128];
  307.     new pname[MAX_PLAYER_NAME];
  308.     GetPlayerName(playerid, pname, sizeof(pname));
  309.     new randommsg = random(4);
  310.     switch(randommsg)
  311.     {
  312.         case 0: format(string, sizeof(string), "|- %s: %s se conecto al servidor", Botname, pname);
  313.         case 1: format(string, sizeof(string), "|- %s: Bienvenido a %s, %s", Botname, ServerName, pname);
  314.         case 2: format(string, sizeof(string), "|- %s: No olviden visitar %s (Va para ti, %s)", Botname, ServerURL, pname);
  315.         case 3: format(string, sizeof(string), "|- %s: Si ven algun cheater, utilizen /report [ID] [Razon]", Botname);
  316.     }
  317.     SendClientMessageToAll(LIGHTBLUE, string);
  318. }
  319.  
  320. stock ChangeNameD(playerid, inputtext[])
  321. {
  322.     new str[128];
  323.     format(Botname, MAX_PLAYER_NAME, "%s", inputtext);
  324.     format(str, sizeof(str), "El nombre del Chatbot ahora es %s", Botname);
  325.     ShowPlayerDialog(playerid, BotD5, DIALOG_STYLE_MSGBOX, Botname, str, "Aceptar", "");
  326. }
  327.  
  328. stock ChangeURL(playerid, inputtext[])
  329. {
  330.     new str[128];
  331.     format(ServerURL, sizeof(ServerURL), "%s", inputtext);
  332.     format(str, sizeof(str), "La nueva URL del servidor es %s", ServerURL);
  333.     ShowPlayerDialog(playerid, BotD5, DIALOG_STYLE_MSGBOX, Botname, str, "Aceptar", "");
  334.     format(str, sizeof(str), "No olviden visitar %s!", ServerURL);
  335.     SendBotMessage(str);
  336.     format(str, sizeof(str), "weburl %s", ServerURL);
  337.     SendRconCommand(str);
  338. }
  339.  
  340. stock ChangeSVN(playerid, inputtext[])
  341. {
  342.     new str[128];
  343.     format(ServerName, sizeof(ServerName), "%s", inputtext);
  344.     format(str, sizeof(str), "El nombre del servidor ahora es %s", ServerName);
  345.     ShowPlayerDialog(playerid, BotD5, DIALOG_STYLE_MSGBOX, Botname, str, "Aceptar", "");
  346.     SendBotMessage(str);
  347. }
  348. //==================================================================Fin Chatbot!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement