Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define DialogRCON 1920
- #define DialogRCON2 1921
- // Descomenta la siguiente linea si deseas activar la opción de ver los jugadores (CONSUME MUCHA MEMORIA)
- //#define VerJugadores
- // IMPORTANTE: coloca aquí la cantidad de slots de tu servidor (sólo será necesario si activaste la opción de ver los jugadores)
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 500
- public OnFilterScriptInit()
- {
- print("*** DialogRCON by iDarkRain - Cargado ***");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("*** DialogRCON by iDarkRain - Descargado ***");
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- DeletePVar(playerid, "DialogRCON");
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/drcon", cmdtext, true, 6) == 0 && IsPlayerAdmin(playerid))
- {
- new dialog[590] = "Cerrar el servidor";
- strcat(dialog, "\nEnviar mensaje a la consola");
- strcat(dialog, "\nCambiar nombre del servidor");
- strcat(dialog, "\nCambiar modo de juego");
- strcat(dialog, "\nCambiar nombre de mapa");
- strcat(dialog, "\nEjecutar un archivo de configuración externo");
- strcat(dialog, "\nKickear un jugador");
- strcat(dialog, "\nBanear un jugador");
- strcat(dialog, "\nCambiar de gamemode");
- strcat(dialog, "\nRecargar samp.ban");
- strcat(dialog, "\nRecargar server_log.txt");
- strcat(dialog, "\nEnviar mensaje a los jugadores");
- strcat(dialog, "\nMostrar los jugadores conectados");
- strcat(dialog, "\nBanear una IP específica");
- strcat(dialog, "\nDesbanear una IP específica");
- strcat(dialog, "\nCambiar la gravedad");
- strcat(dialog, "\nCambiar el clima");
- strcat(dialog, "\nCargar un filterscript específico");
- strcat(dialog, "\nCambiar la página web del servidor");
- strcat(dialog, "\nDescargar un filterscript específico");
- strcat(dialog, "\nRecargar un filterscript específico");
- strcat(dialog, "\nCambiar la contraseña de RCON");
- ShowPlayerDialog(playerid, DialogRCON, DIALOG_STYLE_LIST, "DialogRCON by iDarkRain", dialog, "Entrar", "Salir");
- return 1;
- }
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case DialogRCON:
- {
- if(!response) return 1;
- if(!IsPlayerAdmin(playerid)) return 1;
- if(listitem == 0) { SendRconCommand("exit"); return 1; }
- if(listitem == 1)
- {
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_INPUT, inputtext, "Escribe el mensaje que deseas enviar a la consola del servidor.", "Enviar", "Cancelar");
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- if(listitem == 2)
- {
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_INPUT, inputtext, "Escribe el nuevo nombre para el nombre del servidor que desea poner.", "Cambiar", "Cancelar");
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- if(listitem == 3)
- {
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_INPUT, inputtext, "Escribe el nuevo nombre para el modo de juego que desea poner.", "Cambiar", "Cancelar");
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- if(listitem == 4)
- {
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_INPUT, inputtext, "Escribe el nuevo nombre para el nombre del mapa que desea poner.", "Cambiar", "Cancelar");
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- if(listitem == 5)
- {
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_INPUT, inputtext, "Escribe el nombre del archivo de configuración externo\nEjemplo: blah.cfg", "Ejecutar", "Cancelar");
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- if(listitem == 6)
- {
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_INPUT, inputtext, "Escribe el ID o parte del nombre del jugador que desea kickear", "Kickear", "Cancelar");
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- if(listitem == 7)
- {
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_INPUT, inputtext, "Escribe el ID o parte del nombre del jugador que desea banear", "Banear", "Cancelar");
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- if(listitem == 8)
- {
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_INPUT, inputtext, "Escribe el nombre del gamemode que desea usar\nNo es necesario colocar el '.amx' al final", "Cambiar", "Cancelar");
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- if(listitem == 9)
- {
- SendRconCommand("reloadbans");
- SendClientMessage(playerid, -1, "Archivo de baneos");
- SendClientMessage(playerid, -1, "--------");
- SendClientMessage(playerid, -1, " Cargado: samp.ban");
- return 1;
- }
- if(listitem == 10)
- {
- SendRconCommand("reloadlog");
- SendClientMessage(playerid, -1, "---------");
- SendClientMessage(playerid, -1, "Archivo de log recargado: 'server_log.txt'.");
- SendClientMessage(playerid, -1, "---------");
- return 1;
- }
- if(listitem == 11)
- {
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_INPUT, inputtext, "Escribe el mensaje que desea enviar a los jugadores.", "Enviar", "Cancelar");
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- if(listitem == 12)
- {
- #if defined VerJugadores
- new dialog[76*MAX_PLAYERS], string[76], ip[16], nombre[MAX_PLAYER_NAME];
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- GetPlayerName(i, nombre, sizeof(nombre));
- GetPlayerIp(i, ip, sizeof(ip));
- if(IsPlayerNPC(playerid)) format(string, sizeof(string), "[BOT] [ID: %d] %s - IP: %s - Ping: %d\n", i, nombre, ip, GetPlayerPing(i));
- else format(string, sizeof(string), "[ID: %d] %s - IP: %s - Ping: %d\n", i, nombre, ip, GetPlayerPing(i));
- strcat(dialog, string);
- }
- }
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_MSGBOX, inputtext, dialog, "Ok", "");
- #else
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_MSGBOX, inputtext, "Esta opción debe activarse en el script", "Ok", "");
- #endif
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- if(listitem == 13)
- {
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_INPUT, inputtext, "Escribe la dirección de IP que deseas banear.", "Banear", "Cancelar");
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- if(listitem == 14)
- {
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_INPUT, inputtext, "Escribe la dirección de IP que deseas desbanear.", "Desbanear", "Cancelar");
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- if(listitem == 15)
- {
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_INPUT, inputtext, "Escribe la cantidad de gravedad que desea colocar.", "Colocar", "Cancelar");
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- if(listitem == 16)
- {
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_INPUT, inputtext, "Escribe la ID del clima que desea colocar.", "Colocar", "Cancelar");
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- if(listitem == 17)
- {
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_INPUT, inputtext, "Escribe el nombre del filterscript que desea cargar\nNo es necesario colocar el '.amx' al final", "Cargar", "Cancelar");
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- if(listitem == 18)
- {
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_INPUT, inputtext, "Escribe la URL de la página web que deseas colocar.", "Colocar", "Cancelar");
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- if(listitem == 19)
- {
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_INPUT, inputtext, "Escribe el nombre del filterscript que desea descargar\nNo es necesario colocar el '.amx' al final", "Descargar", "Cancelar");
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- if(listitem == 20)
- {
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_INPUT, inputtext, "Escribe el nombre del filterscript que desea recargar\nNo es necesario colocar el '.amx' al final", "Recargar", "Cancelar");
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- if(listitem == 21)
- {
- ShowPlayerDialog(playerid, DialogRCON2, DIALOG_STYLE_PASSWORD, inputtext, "Escribe la nueva contraseña del RCON que deseas colocar.", "Cambiar", "Cancelar");
- SetPVarInt(playerid, "DialogRCON", listitem);
- return 1;
- }
- return 1;
- }
- case DialogRCON2:
- {
- new string[256];
- if(!response) return 1;
- if(!IsPlayerAdmin(playerid)) return 1;
- if(GetPVarInt(playerid, "DialogRCON") == 1)
- {
- format(string, sizeof(string), "echo %s", inputtext);
- SendRconCommand(string);
- }
- if(GetPVarInt(playerid, "DialogRCON") == 2)
- {
- format(string, sizeof(string), "hostname %s", inputtext);
- SendRconCommand(string);
- }
- if(GetPVarInt(playerid, "DialogRCON") == 3)
- {
- format(string, sizeof(string), "gamemodetext %s", inputtext);
- SendRconCommand(string);
- }
- if(GetPVarInt(playerid, "DialogRCON") == 4)
- {
- format(string, sizeof(string), "mapname %s", inputtext);
- SendRconCommand(string);
- }
- if(GetPVarInt(playerid, "DialogRCON") == 5)
- {
- format(string, sizeof(string), "exec %s", inputtext);
- SendRconCommand(string);
- }
- if(GetPVarInt(playerid, "DialogRCON") == 6)
- {
- new usuario = ReturnUser(inputtext);
- if(IsPlayerConnected(usuario)) Kick(usuario);
- }
- if(GetPVarInt(playerid, "DialogRCON") == 7)
- {
- new usuario = ReturnUser(inputtext);
- if(IsPlayerConnected(usuario)) Ban(usuario);
- }
- if(GetPVarInt(playerid, "DialogRCON") == 8)
- {
- format(string, sizeof(string), "changemode %s", inputtext);
- SendRconCommand(string);
- }
- if(GetPVarInt(playerid, "DialogRCON") == 11)
- {
- format(string, sizeof(string), "say %s", inputtext);
- SendRconCommand(string);
- }
- if(GetPVarInt(playerid, "DialogRCON") == 13)
- {
- format(string, sizeof(string), "banip %s", inputtext);
- SendRconCommand(string);
- SendRconCommand("reloadbans");
- }
- if(GetPVarInt(playerid, "DialogRCON") == 14)
- {
- format(string, sizeof(string), "unbanip %s", inputtext);
- SendRconCommand(string);
- SendRconCommand("reloadbans");
- }
- if(GetPVarInt(playerid, "DialogRCON") == 15)
- {
- SetGravity(floatstr(inputtext));
- }
- if(GetPVarInt(playerid, "DialogRCON") == 16)
- {
- SetWeather(strval(inputtext));
- }
- if(GetPVarInt(playerid, "DialogRCON") == 17)
- {
- format(string, sizeof(string), "loadfs %s", inputtext);
- SendRconCommand(string);
- }
- if(GetPVarInt(playerid, "DialogRCON") == 18)
- {
- format(string, sizeof(string), "weburl %s", inputtext);
- SendRconCommand(string);
- }
- if(GetPVarInt(playerid, "DialogRCON") == 19)
- {
- format(string, sizeof(string), "unloadfs %s", inputtext);
- SendRconCommand(string);
- }
- if(GetPVarInt(playerid, "DialogRCON") == 20)
- {
- format(string, sizeof(string), "reloadfs %s", inputtext);
- SendRconCommand(string);
- }
- if(GetPVarInt(playerid, "DialogRCON") == 21)
- {
- format(string, sizeof(string), "rcon_password %s", inputtext);
- SendRconCommand(string);
- }
- return 1;
- }
- }
- return 0;
- }
- stock IsNumeric(const string[])
- {
- for (new i = 0, j = strlen(string); i < j; i++)
- {
- if (string[i] > '9' || string[i] < '0') return 0;
- }
- return 1;
- }
- stock ReturnUser(text[], playerid = INVALID_PLAYER_ID)
- {
- new pos = 0;
- while (text[pos] < 0x21) // Strip out leading spaces
- {
- if (text[pos] == 0) return INVALID_PLAYER_ID; // No passed text
- pos++;
- }
- new userid = INVALID_PLAYER_ID;
- if (IsNumeric(text[pos])) // Check whole passed string
- {
- // If they have a numeric name you have a problem (although names are checked on id failure)
- userid = strval(text[pos]);
- if (userid >=0 && userid < MAX_PLAYERS)
- {
- if(!IsPlayerConnected(userid))
- {
- /*if (playerid != INVALID_PLAYER_ID)
- {
- SendClientMessage(playerid, 0xFF0000AA, "User not connected");
- }*/
- userid = INVALID_PLAYER_ID;
- }
- else
- {
- return userid; // A player was found
- }
- }
- /*else
- {
- if (playerid != INVALID_PLAYER_ID)
- {
- SendClientMessage(playerid, 0xFF0000AA, "Invalid user ID");
- }
- userid = INVALID_PLAYER_ID;
- }
- return userid;*/
- // Removed for fallthrough code
- }
- // They entered [part of] a name or the id search failed (check names just incase)
- 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) // Check segment of name
- {
- if (len == strlen(name)) // Exact match
- {
- return i; // Return the exact player on an exact match
- // Otherwise if there are two players:
- // Me and MeYou any time you entered Me it would find both
- // And never be able to return just Me's id
- }
- else // Partial match
- {
- count++;
- userid = i;
- }
- }
- }
- }
- if (count != 1)
- {
- if (playerid != INVALID_PLAYER_ID)
- {
- if (count)
- {
- SendClientMessage(playerid, 0xFF0000AA, "Se encontraron múltiples usuarios, intente hacer la búsqueda más específica");
- }
- else
- {
- SendClientMessage(playerid, 0xFF0000AA, "No se encontró ningún usuario");
- }
- }
- userid = INVALID_PLAYER_ID;
- }
- if(IsPlayerNPC(userid)) userid = INVALID_PLAYER_ID;
- return userid; // INVALID_USER_ID for bad return
- }
Advertisement
Add Comment
Please, Sign In to add comment