Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Sistema BadyxRcon Version include By Badyx
- */
- /* Creditos:
- Badyx Crear el include, algunas funciones, sistemas y tester.
- Daniel Utilizado un sistema de verificado de contraseñas echo por el.
- Desconocidos Algunas funciones utilizadas.
- Datos:
- Tiempo 4 horas sin prisa.
- Bugs No conocidos.
- Informacion adicional:
- Todo el sistema esta por dialog.
- Un único comando /MenuRcon.
- No deben de tener en uso los dialogs desde el 9999 al 10009.
- Imagenes:
- www.imageshack.us/a/img10/839/samp045cp.png
- www.imageshack.us/a/img835/7119/samp046rg.png
- www.imageshack.us/photo/my-images/62/samp047rx.png
- www.imageshack.us/photo/my-images/210/samp049sg.png
- */
- #include <a_samp>
- #include <dini>
- /* Macros */
- #define funcion%0(%1) \
- forward %0(%1); \
- public %0(%1)
- #define MenuRcon 9999
- #define RconLogear 10000
- #define RconCambio 10001
- #define RconExpulsar 10002
- #define RconBanear 10003
- #define RconDesBanear 10004
- #define NombreHost 10005
- #define NombreWeb 10006
- #define NombreMapa 10007
- #define RconCargarFs 10008
- #define RconDesCargarFs 10009
- /* Colores */
- #define Rojo 0xa80707FF
- #define Verde 0x1eb032FF
- #define Azul 0x5FFde2FF
- /* News */
- new bool:EstaLogueado[MAX_PLAYERS];
- new Fallo[MAX_PLAYERS];
- Rcon_OnPlayerConnect(playerid)
- {
- EstaLogueado[playerid] = false;
- Fallo[playerid] = 0;
- return 1;
- }
- Rcon_OnPlayerDisconnect(playerid)
- {
- EstaLogueado[playerid] = false;
- Fallo[playerid] = 0;
- return 1;
- }
- Rcon_OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/MenuRcon", cmdtext, true, 10) == 0)
- {
- 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");
- return 1;
- }
- return 0;
- }
- Rcon_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new string[256];
- new giveplayerid;
- new idx;
- new archivo[256];
- new sendcmd[128];
- new mensaje[128];
- new Hora,minuto,segundo;
- gettime(Hora,minuto,segundo);
- if(dialogid == MenuRcon)
- {
- if(response)
- {
- if(listitem == 0)
- {
- ShowPlayerDialog(playerid,RconLogear,DIALOG_STYLE_INPUT,"Ingresar como Rcon","Introduzca la contraseña","Aceptar","Cancelar");
- return 1;
- }
- if (EstaLogueado[playerid] == false)
- {
- SendClientMessage(playerid, Rojo, "[Error] Usted no esta Logeado"); return 1;
- }
- if(listitem == 1)
- {
- ShowPlayerDialog(playerid,RconCambio,DIALOG_STYLE_INPUT,"Cambiar como Rcon","Introduzca la nueva contraseña","Aceptar","Cancelar");
- return 1;
- }
- if(listitem == 2)
- {
- ShowPlayerDialog(playerid,RconExpulsar,DIALOG_STYLE_INPUT,"Expulsar con Rcon","Introduzca la id a expulsar","Expulsar","Cancelar");
- return 1;
- }
- if(listitem == 3)
- {
- ShowPlayerDialog(playerid,RconBanear,DIALOG_STYLE_INPUT,"Banear con Rcon","Introduzca la id a banear","Banear","Cancelar");
- return 1;
- }
- if(listitem == 4)
- {
- ShowPlayerDialog(playerid,RconDesBanear,DIALOG_STYLE_INPUT,"Desbanear con Rcon","Introduzca la id a desbanear","Desbanear","Cancelar");
- return 1;
- }
- if(listitem == 5)
- {
- ShowPlayerDialog(playerid,NombreHost,DIALOG_STYLE_INPUT,"Cambiar el nombre del host con Rcon","Introduzca el nuevo nombre","Cambiar","Cancelar");
- return 1;
- }
- if(listitem == 6)
- {
- ShowPlayerDialog(playerid,NombreWeb,DIALOG_STYLE_INPUT,"Cambiar la paguina web con Rcon","Introduzca la nueva pagina web","Cambiar","Cancelar");
- return 1;
- }
- if(listitem == 7)
- {
- ShowPlayerDialog(playerid,NombreMapa,DIALOG_STYLE_INPUT,"Cambiar el nombre del mapa con Rcon","Introduzca el nuevo nombre para el mapa","Cambiar","Cancelar");
- return 1;
- }
- if(listitem == 8)
- {
- if(IsPlayerConnected(playerid))
- {
- SendRconCommand("exit");
- return 1;
- }
- }
- if(listitem == 9)
- {
- if(IsPlayerConnected(playerid))
- {
- SendRconCommand("gmx");
- return 1;
- }
- }
- if(listitem == 10)
- {
- if(IsPlayerConnected(playerid))
- {
- SendRconCommand("reloadbans");
- return 1;
- }
- }
- if(listitem == 11)
- {
- ShowPlayerDialog(playerid,RconCargarFs,DIALOG_STYLE_INPUT,"Cargar FileScript con Rcon","Introduzca el nombre del FileScript a cargar","Cargar","Cancelar");
- return 1;
- }
- if(listitem == 12)
- {
- ShowPlayerDialog(playerid,RconDesCargarFs,DIALOG_STYLE_INPUT,"Descargar FileScript con Rcon","Introduzca el nombre del FileScript a descargar","Descargar","Cancelar");
- return 1;
- }
- }
- }
- if(dialogid == RconCargarFs && response) /* Badyx */
- {
- if(!strlen(inputtext))
- {
- ShowPlayerDialog(playerid,RconCargarFs,DIALOG_STYLE_INPUT,"Cargar FileScript con Rcon","Introduzca el nombre del FileScript a cargar","Cargar","Cancelar");
- return 1;
- }
- format(sendcmd, sizeof(sendcmd), "Loadfs %s", inputtext);
- SendRconCommand(sendcmd);
- format(string, sizeof(string), "[RconBadyx] %s a cargado el FileScript %s",NombreEx(playerid),inputtext);
- LogeadoRcon(Rojo,string);
- return 1;
- }
- if(dialogid == RconDesCargarFs && response) /* Badyx */
- {
- if(!strlen(inputtext))
- {
- ShowPlayerDialog(playerid,RconDesCargarFs,DIALOG_STYLE_INPUT,"Descargar FileScript con Rcon","Introduzca el nombre del FileScript a descargar","Descargar","Cancelar");
- return 1;
- }
- format(sendcmd, sizeof(sendcmd), "unloadfs %s", inputtext);
- SendRconCommand(sendcmd);
- format(string, sizeof(string), "[RconBadyx] %s a descargado el FileScript %s",NombreEx(playerid),inputtext);
- LogeadoRcon(Rojo,string);
- return 1;
- }
- if(dialogid == RconDesBanear && response) /* Badyx */
- {
- if(!strlen(inputtext))
- {
- ShowPlayerDialog(playerid,RconDesBanear,DIALOG_STYLE_INPUT,"Desbanear con Rcon","Introduzca la id a desbanear","Desbanear","Cancelar");
- return 1;
- }
- format(sendcmd, sizeof(sendcmd), "unbanip %s", inputtext);
- SendRconCommand(sendcmd);
- format(string, sizeof(string), "[RconBadyx] %s a baneado a %s",NombreEx(playerid),inputtext);
- LogeadoRcon(Rojo,string);
- return 1;
- }
- if(dialogid == RconBanear && response) /* Badyx */
- {
- if(!strlen(inputtext))
- {
- ShowPlayerDialog(playerid,RconBanear,DIALOG_STYLE_INPUT,"Banear con Rcon","Introduzca la id a banear","Banear","Cancelar");
- return 1;
- }
- giveplayerid = ReturnUser(inputtext);
- if(IsPlayerConnected(giveplayerid))
- {
- if(giveplayerid != INVALID_PLAYER_ID)
- {
- new length = strlen(inputtext);
- while ((idx < length) && (inputtext[idx] <= ' '))
- {
- idx++;
- }
- format(sendcmd, sizeof(sendcmd), "banip %s", inputtext);
- SendRconCommand(sendcmd);
- format(string, sizeof(string), "[RconBadyx] %s a baneado a %s",NombreEx(playerid),inputtext);
- LogeadoRcon(Rojo,string);
- return 1;
- }
- }
- return SendClientMessage(playerid, Rojo, "[Error] La id introducida no es correcta");
- }
- if(dialogid == NombreMapa && response) /* Badyx */
- {
- if(!strlen(inputtext))
- {
- ShowPlayerDialog(playerid,NombreMapa,DIALOG_STYLE_INPUT,"Cambiar el nombre del mapa con Rcon","Introduzca el nuevo nombre para el mapa","Cambiar","Cancelar");
- return 1;
- }
- format(string, sizeof(string), "[Atencion] El usuario %s con la id %s a cambiado el nombre del mapa a %s", NombreEx(playerid), playerid, inputtext);
- LogeadoRcon(Rojo,string);
- format(sendcmd, sizeof(sendcmd), "mapname %s", inputtext);
- SendRconCommand(sendcmd);
- return 1;
- }
- if(dialogid == NombreWeb && response) /* Badyx */
- {
- if(!strlen(inputtext))
- {
- ShowPlayerDialog(playerid,NombreWeb,DIALOG_STYLE_INPUT,"Cambiar la paguina web con Rcon","Introduzca la nueva pagina web","Cambiar","Cancelar");
- return 1;
- }
- 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);
- LogeadoRcon(Rojo,string);
- format(sendcmd, sizeof(sendcmd), "Pagina web %s", inputtext);
- SendRconCommand(sendcmd);
- return 1;
- }
- if(dialogid == NombreHost && response) /* Badyx */
- {
- if(!strlen(inputtext))
- {
- ShowPlayerDialog(playerid,NombreHost,DIALOG_STYLE_INPUT,"Cambiar el nombre del host con Rcon","Introduzca el nuevo nombre","Cambiar","Cancelar");
- return 1;
- }
- format(string, sizeof(string), "[Atencion] El usuario %s con la id %s a cambiado el nombre del host a %s", NombreEx(playerid), playerid, inputtext);
- LogeadoRcon(Rojo,string);
- format(sendcmd, sizeof(sendcmd), "hostname %s", inputtext);
- SendRconCommand(sendcmd);
- return 1;
- }
- if(dialogid == RconExpulsar && response) /* Badyx */
- {
- if(!strlen(inputtext))
- {
- ShowPlayerDialog(playerid,RconExpulsar,DIALOG_STYLE_INPUT,"Expulsar con Rcon","Introduzca la id a expulsar","Expulsar","Cancelar");
- return 1;
- }
- giveplayerid = ReturnUser(inputtext);
- if(IsPlayerConnected(giveplayerid))
- {
- if(giveplayerid != INVALID_PLAYER_ID)
- {
- new length = strlen(inputtext);
- while ((idx < length) && (inputtext[idx] <= ' '))
- {
- idx++;
- }
- format(string, sizeof(string), "[RconBadyx] %s fue expulsado por %s [%d:%d:%d]",NombreEx(playerid),NombreEx(giveplayerid),Hora, minuto,segundo);
- LogeadoRcon(Rojo,string);
- Kick(giveplayerid);
- return 1;
- }
- }
- return SendClientMessage(playerid, Rojo, "[Error] La id introducida no esta conectada");
- }
- if(dialogid == RconCambio && response) /* Daniel - Badyx */
- {
- if(!strlen(inputtext))return SendClientMessage(playerid, Azul, "Utiliza: /contraseña [Contraseña]");
- format(archivo, sizeof(archivo), "Rcon/Contraseñas.Rcon");
- 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; }
- dini_IntSet(archivo, "Contraseña Actual ", 0);
- dini_Set(archivo, "Contraseña Actual ", inputtext);
- format(mensaje, sizeof(mensaje), "Contraseña: {00FFFF}%s{FFFFFF} establecida correctamente.!", inputtext);
- SendClientMessage(playerid, Verde, mensaje);
- return 1;
- }
- if(dialogid == RconLogear && response) /* Daniel - Badyx */
- {
- if (!strlen(inputtext)) return ShowPlayerDialog(playerid,RconLogear,DIALOG_STYLE_INPUT,"Ingresar como Rcon","Introduzca la contraseña","Aceptar","Cancelar");
- format(archivo, sizeof(archivo), "Rcon/Contraseñas.Rcon");
- format(string, sizeof(string), "%s", dini_Get(archivo, "Contraseña Actual "));
- if (!strcmp (inputtext, string))
- {
- SendClientMessage(playerid, Verde, "La contraseña ¡Es Correcta!");
- EstaLogueado[playerid] = true;
- format(string, sizeof(string), "[Atencion] El usuario %s con la id %s a logueado con el sistema Rcon", NombreEx(playerid), playerid);
- LogeadoRcon(Rojo,string);
- return 1;
- }
- else
- {
- SendClientMessage(playerid, Rojo, "[Error] La contraseña no coincide.");
- Fallo[playerid] += 1;
- if(Fallo[playerid] > 1)
- {
- Ban(playerid);
- format(string, sizeof(string), "[Atencion] El usuario %s con la id %s fue baneado por fallar entrando con la rcon", NombreEx(playerid), playerid);
- LogeadoRcon(Rojo,string);
- return 1;
- }
- return 1;
- }
- }
- return 1;
- }
- funcion LogRcon(string[]) /* Badyx */
- {
- new entry[256];
- format(entry, sizeof(entry), "%s\r\n",string);
- new File:hFile;
- hFile = fopen("Rcon/LogRcon.ini", io_append);
- fwrite(hFile, entry);
- fclose(hFile);
- }
- stock NombreEx(playerid) /* Desconocido */
- {
- new string[24];
- GetPlayerName(playerid,string,24);
- new str[24];
- strmid(str,string,0,strlen(string),24);
- for(new i = 0; i < MAX_PLAYER_NAME; i++)
- {
- if (str[i] == '_') str[i] = ' ';
- }
- return str;
- }
- stock LogeadoRcon(color,const stringe[]) /* Badyx */
- {
- new string[128];
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if (EstaLogueado[i] == true)
- {
- SendClientMessage(i, color, stringe);
- }
- }
- }
- printf("%s", stringe);
- LogRcon(string);
- return 1;
- }
- stock ReturnUser(text[], playerid = INVALID_PLAYER_ID) /* Desconocido */
- {
- new pos = 0;
- while (text[pos] < 0x21)
- {
- if (text[pos] == 0) return INVALID_PLAYER_ID;
- pos++;
- }
- new userid = INVALID_PLAYER_ID;
- if (IsNumeric(text[pos]))
- {
- userid = strval(text[pos]);
- if (userid >=0 && userid < MAX_PLAYERS)
- {
- if(!IsPlayerConnected(userid))
- {
- userid = INVALID_PLAYER_ID;
- }
- else
- {
- return userid;
- }
- }
- }
- new len = strlen(text[pos]);
- new count = 0;
- new name[MAX_PLAYER_NAME];
- for (new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- GetPlayerName(i, name, sizeof (name));
- if (strcmp(name, text[pos], true, len) == 0)
- {
- if (len == strlen(name))
- {
- return i;
- }
- else
- {
- count++;
- userid = i;
- }
- }
- }
- }
- if (count != 1)
- {
- if (playerid != INVALID_PLAYER_ID)
- {
- if (count)
- {
- }
- else
- {
- }
- }
- userid = INVALID_PLAYER_ID;
- }
- return userid;
- }
- 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 */
- //============================================================================//
- // //
- // Final del Script //
- // //
- // Creditos en la cabecera del script //
- // //
- // Si te sirvio, respeta el trabajo del creador //
- // //
- //============================================================================//
Advertisement
Add Comment
Please, Sign In to add comment