Badyx

[Include] BadyXRcon

Oct 25th, 2012
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 14.20 KB | None | 0 0
  1. /*
  2.         Sistema BadyxRcon Version include By Badyx
  3.                                                         */
  4.  
  5. /*      Creditos:
  6.  
  7.         Badyx               Crear el include, algunas funciones, sistemas y tester.
  8.         Daniel              Utilizado un sistema de verificado de contraseñas echo por el.
  9.         Desconocidos        Algunas funciones utilizadas.
  10.  
  11.  
  12.         Datos:
  13.  
  14.         Tiempo              4 horas sin prisa.
  15.         Bugs                No conocidos.
  16.  
  17.         Informacion adicional:
  18.  
  19.         Todo el sistema esta por dialog.
  20.  
  21.         Un único comando /MenuRcon.
  22.         No deben de tener en uso los dialogs desde el 9999 al   10009.
  23.  
  24.         Imagenes:
  25.  
  26.  
  27.         www.imageshack.us/a/img10/839/samp045cp.png
  28.  
  29.         www.imageshack.us/a/img835/7119/samp046rg.png
  30.  
  31.         www.imageshack.us/photo/my-images/62/samp047rx.png
  32.  
  33.         www.imageshack.us/photo/my-images/210/samp049sg.png
  34.  
  35. */
  36. #include <a_samp>
  37. #include <dini>
  38.  
  39. /*               Macros              */
  40. #define funcion%0(%1) \
  41.                      forward %0(%1); \
  42.                                     public %0(%1)
  43.  
  44. #define MenuRcon 9999
  45. #define RconLogear 10000
  46. #define RconCambio 10001
  47. #define RconExpulsar 10002
  48. #define RconBanear 10003
  49. #define RconDesBanear 10004
  50. #define NombreHost 10005
  51. #define NombreWeb 10006
  52. #define NombreMapa 10007
  53. #define RconCargarFs 10008
  54. #define RconDesCargarFs 10009
  55.  
  56.  
  57.  
  58. /*              Colores             */
  59.  
  60. #define Rojo 0xa80707FF
  61. #define Verde 0x1eb032FF
  62. #define Azul 0x5FFde2FF
  63. /*              News                */
  64.  
  65. new bool:EstaLogueado[MAX_PLAYERS];
  66. new Fallo[MAX_PLAYERS];
  67.  
  68. Rcon_OnPlayerConnect(playerid)
  69. {
  70.     EstaLogueado[playerid] = false;
  71.     Fallo[playerid] = 0;
  72.     return 1;
  73. }
  74.  
  75. Rcon_OnPlayerDisconnect(playerid)
  76. {
  77.     EstaLogueado[playerid] = false;
  78.     Fallo[playerid] = 0;
  79.     return 1;
  80. }
  81.  
  82. Rcon_OnPlayerCommandText(playerid, cmdtext[])
  83. {
  84.  
  85.     if (strcmp("/MenuRcon", cmdtext, true, 10) == 0)
  86.     {
  87.     ShowPlayerDialog(playerid,MenuRcon, DIALOG_STYLE_LIST, "Sistema Rcon", "Logear\nCambiar Rcon\nExpulsar\nBanear\nDesbanear\nNombreHost\nNombreWeb\nNombreMapa\nApagar Servidor\nReiniciar Servidor\nRecargar Bans\nCargar FileScript\nDescargar FileScript", "Aceptar", "Cancelar");
  88.     return 1;
  89.     }
  90.  
  91.  
  92.     return 0;
  93. }
  94. Rcon_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  95. {
  96.     new string[256];
  97.     new giveplayerid;
  98.     new idx;
  99.     new archivo[256];
  100.     new sendcmd[128];
  101.     new mensaje[128];
  102.     new Hora,minuto,segundo;
  103.     gettime(Hora,minuto,segundo);
  104.     if(dialogid == MenuRcon)
  105.     {
  106.  
  107.         if(response)
  108.         {
  109.         if(listitem == 0)
  110.         {
  111.         ShowPlayerDialog(playerid,RconLogear,DIALOG_STYLE_INPUT,"Ingresar como Rcon","Introduzca la contraseña","Aceptar","Cancelar");
  112.         return 1;
  113.         }
  114.         if (EstaLogueado[playerid] == false)
  115.         {
  116.             SendClientMessage(playerid, Rojo, "[Error] Usted no esta Logeado"); return 1;
  117.         }
  118.         if(listitem == 1)
  119.         {
  120.         ShowPlayerDialog(playerid,RconCambio,DIALOG_STYLE_INPUT,"Cambiar como Rcon","Introduzca la nueva contraseña","Aceptar","Cancelar");
  121.         return 1;
  122.         }
  123.         if(listitem == 2)
  124.         {
  125.         ShowPlayerDialog(playerid,RconExpulsar,DIALOG_STYLE_INPUT,"Expulsar con Rcon","Introduzca la id a expulsar","Expulsar","Cancelar");
  126.         return 1;
  127.         }
  128.         if(listitem == 3)
  129.         {
  130.         ShowPlayerDialog(playerid,RconBanear,DIALOG_STYLE_INPUT,"Banear con Rcon","Introduzca la id a banear","Banear","Cancelar");
  131.         return 1;
  132.         }
  133.         if(listitem == 4)
  134.         {
  135.         ShowPlayerDialog(playerid,RconDesBanear,DIALOG_STYLE_INPUT,"Desbanear con Rcon","Introduzca la id a desbanear","Desbanear","Cancelar");
  136.         return 1;
  137.         }
  138.         if(listitem == 5)
  139.         {
  140.         ShowPlayerDialog(playerid,NombreHost,DIALOG_STYLE_INPUT,"Cambiar el nombre del host con Rcon","Introduzca el nuevo nombre","Cambiar","Cancelar");
  141.         return 1;
  142.         }
  143.         if(listitem == 6)
  144.         {
  145.         ShowPlayerDialog(playerid,NombreWeb,DIALOG_STYLE_INPUT,"Cambiar la paguina web con Rcon","Introduzca la nueva pagina web","Cambiar","Cancelar");
  146.         return 1;
  147.         }
  148.         if(listitem == 7)
  149.         {
  150.         ShowPlayerDialog(playerid,NombreMapa,DIALOG_STYLE_INPUT,"Cambiar el nombre del mapa con Rcon","Introduzca el nuevo nombre para el mapa","Cambiar","Cancelar");
  151.         return 1;
  152.         }
  153.         if(listitem == 8)
  154.         {
  155.         if(IsPlayerConnected(playerid))
  156.         {
  157.             SendRconCommand("exit");
  158.             return 1;
  159.         }
  160.         }
  161.         if(listitem == 9)
  162.         {
  163.         if(IsPlayerConnected(playerid))
  164.         {
  165.             SendRconCommand("gmx");
  166.             return 1;
  167.         }
  168.         }
  169.         if(listitem == 10)
  170.         {
  171.         if(IsPlayerConnected(playerid))
  172.         {
  173.             SendRconCommand("reloadbans");
  174.             return 1;
  175.         }
  176.         }
  177.         if(listitem == 11)
  178.         {
  179.             ShowPlayerDialog(playerid,RconCargarFs,DIALOG_STYLE_INPUT,"Cargar FileScript con Rcon","Introduzca el nombre del FileScript a cargar","Cargar","Cancelar");
  180.             return 1;
  181.         }
  182.         if(listitem == 12)
  183.         {
  184.             ShowPlayerDialog(playerid,RconDesCargarFs,DIALOG_STYLE_INPUT,"Descargar FileScript con Rcon","Introduzca el nombre del FileScript a descargar","Descargar","Cancelar");
  185.             return 1;
  186.         }
  187.         }
  188.     }
  189.  
  190.     if(dialogid == RconCargarFs && response)        /*      Badyx       */
  191.     {
  192.     if(!strlen(inputtext))
  193.     {
  194.         ShowPlayerDialog(playerid,RconCargarFs,DIALOG_STYLE_INPUT,"Cargar FileScript con Rcon","Introduzca el nombre del FileScript a cargar","Cargar","Cancelar");
  195.         return 1;
  196.     }
  197.     format(sendcmd, sizeof(sendcmd), "Loadfs %s", inputtext);
  198.     SendRconCommand(sendcmd);
  199.     format(string, sizeof(string), "[RconBadyx] %s a cargado el FileScript %s",NombreEx(playerid),inputtext);
  200.     LogeadoRcon(Rojo,string);
  201.     return 1;
  202.     }
  203.  
  204.     if(dialogid == RconDesCargarFs && response)        /*      Badyx       */
  205.     {
  206.     if(!strlen(inputtext))
  207.     {
  208.         ShowPlayerDialog(playerid,RconDesCargarFs,DIALOG_STYLE_INPUT,"Descargar FileScript con Rcon","Introduzca el nombre del FileScript a descargar","Descargar","Cancelar");
  209.         return 1;
  210.     }
  211.     format(sendcmd, sizeof(sendcmd), "unloadfs %s", inputtext);
  212.     SendRconCommand(sendcmd);
  213.     format(string, sizeof(string), "[RconBadyx] %s a descargado el FileScript %s",NombreEx(playerid),inputtext);
  214.     LogeadoRcon(Rojo,string);
  215.     return 1;
  216.     }
  217.  
  218.     if(dialogid == RconDesBanear && response)        /*      Badyx       */
  219.     {
  220.     if(!strlen(inputtext))
  221.     {
  222.         ShowPlayerDialog(playerid,RconDesBanear,DIALOG_STYLE_INPUT,"Desbanear con Rcon","Introduzca la id a desbanear","Desbanear","Cancelar");
  223.         return 1;
  224.     }
  225.     format(sendcmd, sizeof(sendcmd), "unbanip %s", inputtext);
  226.     SendRconCommand(sendcmd);
  227.     format(string, sizeof(string), "[RconBadyx] %s a baneado a %s",NombreEx(playerid),inputtext);
  228.     LogeadoRcon(Rojo,string);
  229.     return 1;
  230.     }
  231.  
  232.     if(dialogid == RconBanear && response)        /*      Badyx       */
  233.     {
  234.     if(!strlen(inputtext))
  235.     {
  236.         ShowPlayerDialog(playerid,RconBanear,DIALOG_STYLE_INPUT,"Banear con Rcon","Introduzca la id a banear","Banear","Cancelar");
  237.         return 1;
  238.     }
  239.     giveplayerid = ReturnUser(inputtext);
  240.     if(IsPlayerConnected(giveplayerid))
  241.     {
  242.         if(giveplayerid != INVALID_PLAYER_ID)
  243.         {
  244.             new length = strlen(inputtext);
  245.             while ((idx < length) && (inputtext[idx] <= ' '))
  246.             {
  247.                 idx++;
  248.             }
  249.             format(sendcmd, sizeof(sendcmd), "banip %s", inputtext);
  250.             SendRconCommand(sendcmd);
  251.             format(string, sizeof(string), "[RconBadyx] %s a baneado a %s",NombreEx(playerid),inputtext);
  252.             LogeadoRcon(Rojo,string);
  253.             return 1;
  254.         }
  255.     }
  256.     return  SendClientMessage(playerid, Rojo, "[Error] La id introducida no es correcta");
  257.     }
  258.  
  259.     if(dialogid == NombreMapa && response)        /*      Badyx       */
  260.     {
  261.     if(!strlen(inputtext))
  262.     {
  263.         ShowPlayerDialog(playerid,NombreMapa,DIALOG_STYLE_INPUT,"Cambiar el nombre del mapa con Rcon","Introduzca el nuevo nombre para el mapa","Cambiar","Cancelar");
  264.         return 1;
  265.     }
  266.     format(string, sizeof(string), "[Atencion] El usuario %s con la id %s a cambiado el nombre del mapa a %s", NombreEx(playerid), playerid, inputtext);
  267.     LogeadoRcon(Rojo,string);
  268.     format(sendcmd, sizeof(sendcmd), "mapname %s", inputtext);
  269.     SendRconCommand(sendcmd);
  270.     return 1;
  271.     }
  272.  
  273.     if(dialogid == NombreWeb && response)        /*      Badyx       */
  274.     {
  275.     if(!strlen(inputtext))
  276.     {
  277.         ShowPlayerDialog(playerid,NombreWeb,DIALOG_STYLE_INPUT,"Cambiar la paguina web con Rcon","Introduzca la nueva pagina web","Cambiar","Cancelar");
  278.         return 1;
  279.     }
  280.     format(string, sizeof(string), "[Atencion] El usuario %s con la id %s a cambiado el nombre de la web a %s", NombreEx(playerid), playerid, inputtext);
  281.     LogeadoRcon(Rojo,string);
  282.     format(sendcmd, sizeof(sendcmd), "Pagina web %s", inputtext);
  283.     SendRconCommand(sendcmd);
  284.     return 1;
  285.     }
  286.  
  287.  
  288.     if(dialogid == NombreHost && response)        /*      Badyx       */
  289.     {
  290.     if(!strlen(inputtext))
  291.     {
  292.         ShowPlayerDialog(playerid,NombreHost,DIALOG_STYLE_INPUT,"Cambiar el nombre del host con Rcon","Introduzca el nuevo nombre","Cambiar","Cancelar");
  293.         return 1;
  294.     }
  295.     format(string, sizeof(string), "[Atencion] El usuario %s con la id %s a cambiado el nombre del host a %s", NombreEx(playerid), playerid, inputtext);
  296.     LogeadoRcon(Rojo,string);
  297.     format(sendcmd, sizeof(sendcmd), "hostname %s", inputtext);
  298.     SendRconCommand(sendcmd);
  299.     return 1;
  300.     }
  301.  
  302.  
  303.  
  304.     if(dialogid == RconExpulsar && response)        /*      Badyx       */
  305.     {
  306.     if(!strlen(inputtext))
  307.     {
  308.         ShowPlayerDialog(playerid,RconExpulsar,DIALOG_STYLE_INPUT,"Expulsar con Rcon","Introduzca la id a expulsar","Expulsar","Cancelar");
  309.         return 1;
  310.     }
  311.  
  312.     giveplayerid = ReturnUser(inputtext);
  313.     if(IsPlayerConnected(giveplayerid))
  314.     {
  315.         if(giveplayerid != INVALID_PLAYER_ID)
  316.         {
  317.             new length = strlen(inputtext);
  318.             while ((idx < length) && (inputtext[idx] <= ' '))
  319.             {
  320.                 idx++;
  321.             }
  322.             format(string, sizeof(string), "[RconBadyx] %s fue expulsado por %s [%d:%d:%d]",NombreEx(playerid),NombreEx(giveplayerid),Hora, minuto,segundo);
  323.             LogeadoRcon(Rojo,string);
  324.             Kick(giveplayerid);
  325.             return 1;
  326.         }
  327.     }
  328.  
  329.     return  SendClientMessage(playerid, Rojo, "[Error] La id introducida no esta conectada");
  330.     }
  331.  
  332.     if(dialogid == RconCambio && response)        /*      Daniel - Badyx       */
  333.     {
  334.     if(!strlen(inputtext))return SendClientMessage(playerid, Azul, "Utiliza: /contraseña [Contraseña]");
  335.     format(archivo, sizeof(archivo), "Rcon/Contraseñas.Rcon");
  336.     if(!dini_Exists(archivo)) { SendClientMessage(playerid, Rojo, "No se pudo leer el Archivo; este fue creado. [Utiliza: /contraseña (Contraseña)]"); dini_Create(archivo); return 1; }
  337.     dini_IntSet(archivo, "Contraseña Actual ", 0);
  338.     dini_Set(archivo, "Contraseña Actual ", inputtext);
  339.     format(mensaje, sizeof(mensaje), "Contraseña: {00FFFF}%s{FFFFFF} establecida correctamente.!", inputtext);
  340.     SendClientMessage(playerid, Verde, mensaje);
  341.     return 1;
  342.     }
  343.  
  344.     if(dialogid == RconLogear && response)        /*      Daniel - Badyx       */
  345.     {
  346.     if (!strlen(inputtext)) return ShowPlayerDialog(playerid,RconLogear,DIALOG_STYLE_INPUT,"Ingresar como Rcon","Introduzca la contraseña","Aceptar","Cancelar");
  347.  
  348.     format(archivo, sizeof(archivo), "Rcon/Contraseñas.Rcon");
  349.     format(string, sizeof(string), "%s", dini_Get(archivo, "Contraseña Actual "));
  350.     if (!strcmp (inputtext, string))
  351.     {
  352.     SendClientMessage(playerid, Verde, "La contraseña ¡Es Correcta!");
  353.     EstaLogueado[playerid] = true;
  354.     format(string, sizeof(string), "[Atencion] El usuario %s con la id %s a logueado con el sistema Rcon", NombreEx(playerid), playerid);
  355.     LogeadoRcon(Rojo,string);
  356.     return 1;
  357.     }
  358.     else
  359.     {
  360.     SendClientMessage(playerid, Rojo, "[Error] La contraseña no coincide.");
  361.     Fallo[playerid] += 1;
  362.     if(Fallo[playerid] > 1)
  363.     {
  364.     Ban(playerid);
  365.     format(string, sizeof(string), "[Atencion] El usuario %s con la id %s fue baneado por fallar entrando con la rcon", NombreEx(playerid), playerid);
  366.     LogeadoRcon(Rojo,string);
  367.     return 1;
  368.     }
  369.     return 1;
  370.     }
  371.     }
  372.  
  373.  
  374.     return 1;
  375. }
  376.  
  377. funcion LogRcon(string[])              /*      Badyx    */
  378. {
  379.     new entry[256];
  380.     format(entry, sizeof(entry), "%s\r\n",string);
  381.     new File:hFile;
  382.     hFile = fopen("Rcon/LogRcon.ini", io_append);
  383.     fwrite(hFile, entry);
  384.     fclose(hFile);
  385. }
  386.  
  387. stock NombreEx(playerid)      /*      Desconocido   */
  388. {
  389.     new string[24];
  390.     GetPlayerName(playerid,string,24);
  391.     new str[24];
  392.     strmid(str,string,0,strlen(string),24);
  393.     for(new i = 0; i < MAX_PLAYER_NAME; i++)
  394.     {
  395.         if (str[i] == '_') str[i] = ' ';
  396.     }
  397.     return str;
  398. }
  399.  
  400.  
  401. stock LogeadoRcon(color,const stringe[])              /*      Badyx     */
  402. {
  403.     new string[128];
  404.     for(new i = 0; i < MAX_PLAYERS; i++)
  405.     {
  406.         if(IsPlayerConnected(i))
  407.         {
  408.             if (EstaLogueado[i] == true)
  409.             {
  410.                 SendClientMessage(i, color, stringe);
  411.  
  412.             }
  413.         }
  414.     }
  415.     printf("%s", stringe);
  416.     LogRcon(string);
  417.     return 1;
  418. }
  419.  
  420.  
  421. stock ReturnUser(text[], playerid = INVALID_PLAYER_ID)            /*      Desconocido   */
  422. {
  423.     new pos = 0;
  424.     while (text[pos] < 0x21)
  425.     {
  426.         if (text[pos] == 0) return INVALID_PLAYER_ID;
  427.         pos++;
  428.     }
  429.     new userid = INVALID_PLAYER_ID;
  430.     if (IsNumeric(text[pos]))
  431.     {
  432.         userid = strval(text[pos]);
  433.         if (userid >=0 && userid < MAX_PLAYERS)
  434.         {
  435.             if(!IsPlayerConnected(userid))
  436.             {
  437.                 userid = INVALID_PLAYER_ID;
  438.             }
  439.             else
  440.             {
  441.                 return userid;
  442.             }
  443.         }
  444.     }
  445.     new len = strlen(text[pos]);
  446.     new count = 0;
  447.     new name[MAX_PLAYER_NAME];
  448.     for (new i = 0; i < MAX_PLAYERS; i++)
  449.     {
  450.         if (IsPlayerConnected(i))
  451.         {
  452.             GetPlayerName(i, name, sizeof (name));
  453.             if (strcmp(name, text[pos], true, len) == 0)
  454.             {
  455.                 if (len == strlen(name))
  456.                 {
  457.                     return i;
  458.                 }
  459.                 else
  460.                 {
  461.                     count++;
  462.                     userid = i;
  463.                 }
  464.             }
  465.         }
  466.     }
  467.     if (count != 1)
  468.     {
  469.         if (playerid != INVALID_PLAYER_ID)
  470.         {
  471.             if (count)
  472.             {
  473.             }
  474.             else
  475.             {
  476.             }
  477.         }
  478.         userid = INVALID_PLAYER_ID;
  479.     }
  480.     return userid;
  481. }
  482.  
  483. stock IsNumeric(stringer[]){for (new i = 0, j = strlen(stringer); i < j; i++) if (stringer[i] > '9' || stringer[i] < '0') return 0; return 1; } /*      Desconocido     */
  484.  
  485.  
  486.  
  487.  
  488. //============================================================================//
  489. //                                                                            //
  490. //                             Final del Script                               //
  491. //                                                                            //
  492. //                      Creditos en la cabecera del script                    //
  493. //                                                                            //
  494. //               Si te sirvio, respeta el trabajo del creador                 //
  495. //                                                                            //
  496. //============================================================================//
Advertisement
Add Comment
Please, Sign In to add comment