Badyx

[Fs] BadyXRcon

Oct 25th, 2012
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 14.46 KB | None | 0 0
  1. /*
  2.         Sistema BadyxRcon By Badyx
  3.                                                         */
  4.                                                        
  5. /*      Creditos:
  6.  
  7.         Badyx               Crear el fs algunas funciones y 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.  
  69.  
  70. #if defined FILTERSCRIPT
  71.  
  72. #else
  73.  
  74. main(){ print("\n----------------------------------");  print(" Sistema Rcon By Badyx");    print("----------------------------------\n");}
  75. #endif
  76.  
  77. funcion OnPlayerConnect(playerid)
  78. {
  79.     EstaLogueado[playerid] = false;
  80.     Fallo[playerid] = 0;
  81.     return 1;
  82. }
  83.  
  84. funcion OnPlayerDisconnect(playerid, reason)
  85. {
  86.     EstaLogueado[playerid] = false;
  87.     Fallo[playerid] = 0;
  88.     return 1;
  89. }
  90.  
  91. funcion OnPlayerCommandText(playerid, cmdtext[])
  92. {
  93.  
  94.     if (strcmp("/MenuRcon", cmdtext, true, 10) == 0)
  95.     {
  96.     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");
  97.     return 1;
  98.     }
  99.  
  100.    
  101.     return 0;
  102. }
  103. funcion OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  104. {
  105.     new string[256];
  106.     new giveplayerid;
  107.     new idx;
  108.     new archivo[256];
  109.     new sendcmd[128];
  110.     new mensaje[128];
  111.     new Hora,minuto,segundo;
  112.     gettime(Hora,minuto,segundo);
  113.     if(dialogid == MenuRcon)
  114.     {
  115.        
  116.         if(response)
  117.         {
  118.         if(listitem == 0)
  119.         {
  120.         ShowPlayerDialog(playerid,RconLogear,DIALOG_STYLE_INPUT,"Ingresar como Rcon","Introduzca la contraseña","Aceptar","Cancelar");
  121.         return 1;
  122.         }
  123.         if (EstaLogueado[playerid] == false)
  124.         {
  125.             SendClientMessage(playerid, Rojo, "[Error] Usted no esta Logeado"); return 1;
  126.         }
  127.         if(listitem == 1)
  128.         {
  129.         ShowPlayerDialog(playerid,RconCambio,DIALOG_STYLE_INPUT,"Cambiar como Rcon","Introduzca la nueva contraseña","Aceptar","Cancelar");
  130.         return 1;
  131.         }
  132.         if(listitem == 2)
  133.         {
  134.         ShowPlayerDialog(playerid,RconExpulsar,DIALOG_STYLE_INPUT,"Expulsar con Rcon","Introduzca la id a expulsar","Expulsar","Cancelar");
  135.         return 1;
  136.         }
  137.         if(listitem == 3)
  138.         {
  139.         ShowPlayerDialog(playerid,RconBanear,DIALOG_STYLE_INPUT,"Banear con Rcon","Introduzca la id a banear","Banear","Cancelar");
  140.         return 1;
  141.         }
  142.         if(listitem == 4)
  143.         {
  144.         ShowPlayerDialog(playerid,RconDesBanear,DIALOG_STYLE_INPUT,"Desbanear con Rcon","Introduzca la id a desbanear","Desbanear","Cancelar");
  145.         return 1;
  146.         }
  147.         if(listitem == 5)
  148.         {
  149.         ShowPlayerDialog(playerid,NombreHost,DIALOG_STYLE_INPUT,"Cambiar el nombre del host con Rcon","Introduzca el nuevo nombre","Cambiar","Cancelar");
  150.         return 1;
  151.         }
  152.         if(listitem == 6)
  153.         {
  154.         ShowPlayerDialog(playerid,NombreWeb,DIALOG_STYLE_INPUT,"Cambiar la paguina web con Rcon","Introduzca la nueva pagina web","Cambiar","Cancelar");
  155.         return 1;
  156.         }
  157.         if(listitem == 7)
  158.         {
  159.         ShowPlayerDialog(playerid,NombreMapa,DIALOG_STYLE_INPUT,"Cambiar el nombre del mapa con Rcon","Introduzca el nuevo nombre para el mapa","Cambiar","Cancelar");
  160.         return 1;
  161.         }
  162.         if(listitem == 8)
  163.         {
  164.         if(IsPlayerConnected(playerid))
  165.         {
  166.             SendRconCommand("exit");
  167.             return 1;
  168.         }
  169.         }
  170.         if(listitem == 9)
  171.         {
  172.         if(IsPlayerConnected(playerid))
  173.         {
  174.             SendRconCommand("gmx");
  175.             return 1;
  176.         }
  177.         }
  178.         if(listitem == 10)
  179.         {
  180.         if(IsPlayerConnected(playerid))
  181.         {
  182.             SendRconCommand("reloadbans");
  183.             return 1;
  184.         }
  185.         }
  186.         if(listitem == 11)
  187.         {
  188.             ShowPlayerDialog(playerid,RconCargarFs,DIALOG_STYLE_INPUT,"Cargar FileScript con Rcon","Introduzca el nombre del FileScript a cargar","Cargar","Cancelar");
  189.             return 1;
  190.         }
  191.         if(listitem == 12)
  192.         {
  193.             ShowPlayerDialog(playerid,RconDesCargarFs,DIALOG_STYLE_INPUT,"Descargar FileScript con Rcon","Introduzca el nombre del FileScript a descargar","Descargar","Cancelar");
  194.             return 1;
  195.         }
  196.         }
  197.     }
  198.        
  199.     if(dialogid == RconCargarFs && response)        /*      Badyx       */
  200.     {
  201.     if(!strlen(inputtext))
  202.     {
  203.         ShowPlayerDialog(playerid,RconCargarFs,DIALOG_STYLE_INPUT,"Cargar FileScript con Rcon","Introduzca el nombre del FileScript a cargar","Cargar","Cancelar");
  204.         return 1;
  205.     }
  206.     format(sendcmd, sizeof(sendcmd), "Loadfs %s", inputtext);
  207.     SendRconCommand(sendcmd);
  208.     format(string, sizeof(string), "[RconBadyx] %s a cargado el FileScript %s",NombreEx(playerid),inputtext);
  209.     LogeadoRcon(Rojo,string);
  210.     return 1;
  211.     }
  212.  
  213.     if(dialogid == RconDesCargarFs && response)        /*      Badyx       */
  214.     {
  215.     if(!strlen(inputtext))
  216.     {
  217.         ShowPlayerDialog(playerid,RconDesCargarFs,DIALOG_STYLE_INPUT,"Descargar FileScript con Rcon","Introduzca el nombre del FileScript a descargar","Descargar","Cancelar");
  218.         return 1;
  219.     }
  220.     format(sendcmd, sizeof(sendcmd), "unloadfs %s", inputtext);
  221.     SendRconCommand(sendcmd);
  222.     format(string, sizeof(string), "[RconBadyx] %s a descargado el FileScript %s",NombreEx(playerid),inputtext);
  223.     LogeadoRcon(Rojo,string);
  224.     return 1;
  225.     }
  226.  
  227.     if(dialogid == RconDesBanear && response)        /*      Badyx       */
  228.     {
  229.     if(!strlen(inputtext))
  230.     {
  231.         ShowPlayerDialog(playerid,RconDesBanear,DIALOG_STYLE_INPUT,"Desbanear con Rcon","Introduzca la id a desbanear","Desbanear","Cancelar");
  232.         return 1;
  233.     }
  234.     format(sendcmd, sizeof(sendcmd), "unbanip %s", inputtext);
  235.     SendRconCommand(sendcmd);
  236.     format(string, sizeof(string), "[RconBadyx] %s a baneado a %s",NombreEx(playerid),inputtext);
  237.     LogeadoRcon(Rojo,string);
  238.     return 1;
  239.     }
  240.  
  241.     if(dialogid == RconBanear && response)        /*      Badyx       */
  242.     {
  243.     if(!strlen(inputtext))
  244.     {
  245.         ShowPlayerDialog(playerid,RconBanear,DIALOG_STYLE_INPUT,"Banear con Rcon","Introduzca la id a banear","Banear","Cancelar");
  246.         return 1;
  247.     }
  248.     giveplayerid = ReturnUser(inputtext);
  249.     if(IsPlayerConnected(giveplayerid))
  250.     {
  251.         if(giveplayerid != INVALID_PLAYER_ID)
  252.         {
  253.             new length = strlen(inputtext);
  254.             while ((idx < length) && (inputtext[idx] <= ' '))
  255.             {
  256.                 idx++;
  257.             }
  258.             format(sendcmd, sizeof(sendcmd), "banip %s", inputtext);
  259.             SendRconCommand(sendcmd);
  260.             format(string, sizeof(string), "[RconBadyx] %s a baneado a %s",NombreEx(playerid),inputtext);
  261.             LogeadoRcon(Rojo,string);
  262.             return 1;
  263.         }
  264.     }
  265.     return  SendClientMessage(playerid, Rojo, "[Error] La id introducida no es correcta");
  266.     }
  267.  
  268.     if(dialogid == NombreMapa && response)        /*      Badyx       */
  269.     {
  270.     if(!strlen(inputtext))
  271.     {
  272.         ShowPlayerDialog(playerid,NombreMapa,DIALOG_STYLE_INPUT,"Cambiar el nombre del mapa con Rcon","Introduzca el nuevo nombre para el mapa","Cambiar","Cancelar");
  273.         return 1;
  274.     }
  275.     format(string, sizeof(string), "[Atencion] El usuario %s con la id %s a cambiado el nombre del mapa a %s", NombreEx(playerid), playerid, inputtext);
  276.     LogeadoRcon(Rojo,string);
  277.     format(sendcmd, sizeof(sendcmd), "mapname %s", inputtext);
  278.     SendRconCommand(sendcmd);
  279.     return 1;
  280.     }
  281.  
  282.     if(dialogid == NombreWeb && response)        /*      Badyx       */
  283.     {
  284.     if(!strlen(inputtext))
  285.     {
  286.         ShowPlayerDialog(playerid,NombreWeb,DIALOG_STYLE_INPUT,"Cambiar la paguina web con Rcon","Introduzca la nueva pagina web","Cambiar","Cancelar");
  287.         return 1;
  288.     }
  289.     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);
  290.     LogeadoRcon(Rojo,string);
  291.     format(sendcmd, sizeof(sendcmd), "Pagina web %s", inputtext);
  292.     SendRconCommand(sendcmd);
  293.     return 1;
  294.     }
  295.  
  296.  
  297.     if(dialogid == NombreHost && response)        /*      Badyx       */
  298.     {
  299.     if(!strlen(inputtext))
  300.     {
  301.         ShowPlayerDialog(playerid,NombreHost,DIALOG_STYLE_INPUT,"Cambiar el nombre del host con Rcon","Introduzca el nuevo nombre","Cambiar","Cancelar");
  302.         return 1;
  303.     }
  304.     format(string, sizeof(string), "[Atencion] El usuario %s con la id %s a cambiado el nombre del host a %s", NombreEx(playerid), playerid, inputtext);
  305.     LogeadoRcon(Rojo,string);
  306.     format(sendcmd, sizeof(sendcmd), "hostname %s", inputtext);
  307.     SendRconCommand(sendcmd);
  308.     return 1;
  309.     }
  310.  
  311.  
  312.  
  313.     if(dialogid == RconExpulsar && response)        /*      Badyx       */
  314.     {
  315.     if(!strlen(inputtext))
  316.     {
  317.         ShowPlayerDialog(playerid,RconExpulsar,DIALOG_STYLE_INPUT,"Expulsar con Rcon","Introduzca la id a expulsar","Expulsar","Cancelar");
  318.         return 1;
  319.     }
  320.  
  321.     giveplayerid = ReturnUser(inputtext);
  322.     if(IsPlayerConnected(giveplayerid))
  323.     {
  324.         if(giveplayerid != INVALID_PLAYER_ID)
  325.         {
  326.             new length = strlen(inputtext);
  327.             while ((idx < length) && (inputtext[idx] <= ' '))
  328.             {
  329.                 idx++;
  330.             }
  331.             format(string, sizeof(string), "[RconBadyx] %s fue expulsado por %s [%d:%d:%d]",NombreEx(playerid),NombreEx(giveplayerid),Hora, minuto,segundo);
  332.             LogeadoRcon(Rojo,string);
  333.             Kick(giveplayerid);
  334.             return 1;
  335.         }
  336.     }
  337.  
  338.     return  SendClientMessage(playerid, Rojo, "[Error] La id introducida no esta conectada");
  339.     }
  340.  
  341.     if(dialogid == RconCambio && response)        /*      Daniel - Badyx       */
  342.     {
  343.     if(!strlen(inputtext))return SendClientMessage(playerid, Azul, "Utiliza: /contraseña [Contraseña]");
  344.     format(archivo, sizeof(archivo), "Rcon/Contraseñas.Rcon");
  345.     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; }
  346.     dini_IntSet(archivo, "Contraseña Actual ", 0);
  347.     dini_Set(archivo, "Contraseña Actual ", inputtext);
  348.     format(mensaje, sizeof(mensaje), "Contraseña: {00FFFF}%s{FFFFFF} establecida correctamente.!", inputtext);
  349.     SendClientMessage(playerid, Verde, mensaje);
  350.     return 1;
  351.     }
  352.  
  353.     if(dialogid == RconLogear && response)        /*      Daniel - Badyx       */
  354.     {
  355.     if (!strlen(inputtext)) return ShowPlayerDialog(playerid,RconLogear,DIALOG_STYLE_INPUT,"Ingresar como Rcon","Introduzca la contraseña","Aceptar","Cancelar");
  356.  
  357.     format(archivo, sizeof(archivo), "Rcon/Contraseñas.Rcon");
  358.     format(string, sizeof(string), "%s", dini_Get(archivo, "Contraseña Actual "));
  359.     if (!strcmp (inputtext, string))
  360.     {
  361.     SendClientMessage(playerid, Verde, "La contraseña ¡Es Correcta!");
  362.     EstaLogueado[playerid] = true;
  363.     format(string, sizeof(string), "[Atencion] El usuario %s con la id %s a logueado con el sistema Rcon", NombreEx(playerid), playerid);
  364.     LogeadoRcon(Rojo,string);
  365.     return 1;
  366.     }
  367.     else
  368.     {
  369.     SendClientMessage(playerid, Rojo, "[Error] La contraseña no coincide.");
  370.     Fallo[playerid] += 1;
  371.     if(Fallo[playerid] > 1)
  372.     {
  373.     Ban(playerid);
  374.     format(string, sizeof(string), "[Atencion] El usuario %s con la id %s fue baneado por fallar entrando con la rcon", NombreEx(playerid), playerid);
  375.     LogeadoRcon(Rojo,string);
  376.     return 1;
  377.     }
  378.     return 1;
  379.     }
  380.     }
  381.        
  382.  
  383.     return 1;
  384. }
  385.  
  386. funcion LogRcon(string[])              /*      Badyx    */
  387. {
  388.     new entry[256];
  389.     format(entry, sizeof(entry), "%s\r\n",string);
  390.     new File:hFile;
  391.     hFile = fopen("Rcon/LogRcon.ini", io_append);
  392.     fwrite(hFile, entry);
  393.     fclose(hFile);
  394. }
  395.  
  396. stock NombreEx(playerid)      /*      Desconocido   */
  397. {
  398.     new string[24];
  399.     GetPlayerName(playerid,string,24);
  400.     new str[24];
  401.     strmid(str,string,0,strlen(string),24);
  402.     for(new i = 0; i < MAX_PLAYER_NAME; i++)
  403.     {
  404.         if (str[i] == '_') str[i] = ' ';
  405.     }
  406.     return str;
  407. }
  408.  
  409.  
  410. stock LogeadoRcon(color,const stringe[])              /*      Badyx     */
  411. {
  412.     new string[128];
  413.     for(new i = 0; i < MAX_PLAYERS; i++)
  414.     {
  415.         if(IsPlayerConnected(i))
  416.         {
  417.             if (EstaLogueado[i] == true)
  418.             {
  419.                 SendClientMessage(i, color, stringe);
  420.                
  421.             }
  422.         }
  423.     }
  424.     printf("%s", stringe);
  425.     LogRcon(string);
  426.     return 1;
  427. }
  428.  
  429.  
  430. stock ReturnUser(text[], playerid = INVALID_PLAYER_ID)            /*      Desconocido   */
  431. {
  432.     new pos = 0;
  433.     while (text[pos] < 0x21)
  434.     {
  435.         if (text[pos] == 0) return INVALID_PLAYER_ID;
  436.         pos++;
  437.     }
  438.     new userid = INVALID_PLAYER_ID;
  439.     if (IsNumeric(text[pos]))
  440.     {
  441.         userid = strval(text[pos]);
  442.         if (userid >=0 && userid < MAX_PLAYERS)
  443.         {
  444.             if(!IsPlayerConnected(userid))
  445.             {
  446.                 userid = INVALID_PLAYER_ID;
  447.             }
  448.             else
  449.             {
  450.                 return userid;
  451.             }
  452.         }
  453.     }
  454.     new len = strlen(text[pos]);
  455.     new count = 0;
  456.     new name[MAX_PLAYER_NAME];
  457.     for (new i = 0; i < MAX_PLAYERS; i++)
  458.     {
  459.         if (IsPlayerConnected(i))
  460.         {
  461.             GetPlayerName(i, name, sizeof (name));
  462.             if (strcmp(name, text[pos], true, len) == 0)
  463.             {
  464.                 if (len == strlen(name))
  465.                 {
  466.                     return i;
  467.                 }
  468.                 else
  469.                 {
  470.                     count++;
  471.                     userid = i;
  472.                 }
  473.             }
  474.         }
  475.     }
  476.     if (count != 1)
  477.     {
  478.         if (playerid != INVALID_PLAYER_ID)
  479.         {
  480.             if (count)
  481.             {
  482.             }
  483.             else
  484.             {
  485.             }
  486.         }
  487.         userid = INVALID_PLAYER_ID;
  488.     }
  489.     return userid;
  490. }
  491.  
  492. 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     */
  493.  
  494.  
  495.  
  496.  
  497. //============================================================================//
  498. //                                                                            //
  499. //                             Final del Script                               //
  500. //                                                                            //
  501. //                      Creditos en la cabecera del script                    //
  502. //                                                                            //
  503. //               Si te sirvio, respeta el trabajo del creador                 //
  504. //                                                                            //
  505. //============================================================================//
Advertisement
Add Comment
Please, Sign In to add comment