Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**************** Sistema Registro & Clanes con Tops DINI *********************/
- //==============================================================================
- // # Sistema Registro & Clanes con Tops DINI
- // # Autor: Zoutdaxv.
- // # Versión: 0.4.2
- // # Fecha: 20/Feb/2010
- // # Actualizado: 01/Jun/2010
- // # Creditos:
- // - » RyDeR «: idea In Game ColorPicker (Sin copiar & pegar).
- // - Zamaroht: TDE & Función RGBA.
- //==============================================================================
- #include <a_samp>
- #include <dini>
- //==============================================================================
- #define DLG_TOP_PLAYERS 1500
- #define DLG_TOP_CLANES 1501
- #define DLG_PLY_INFO 1503
- #define DLG_CLAN_INFO 1504
- //==============================================================================
- #define ROJO 0xAA3333AA
- #define NARANJA 0xF97804FF
- #define BLANCO 0xEFEFF7AA
- #define LIGHTBLUE 0x00C2ECFF
- #define NICESKY 0x99FFFFAA
- //==============================================================================
- #define MAX_DATOS 3000 //NÚMERO DE DATOS QUE SE GUARDARÁN PARA LOS TOPS.
- #define MAX_TOP_PLAYERS 10 //LUGARES QUE SE MOSTRARÁN EN EL TOP PLAYERS
- #define MAX_TOP_CLANES 10 //LUGARES QUE SE MOSTRARÁN EN EL TOP CLANES
- //==============================================================================
- //TOP PLAYERS & TOP CLANES
- enum info
- {
- NickTOP[32],
- AsesinatosTOP,
- MuertesTOP,
- Float:RatioTOP
- };
- new TopInfoP[MAX_TOP_PLAYERS+1][info];
- new TopInfoC[MAX_TOP_CLANES+1][info];
- new TopP[MAX_TOP_PLAYERS+1];
- new TopC[MAX_TOP_CLANES+1];
- new NOMBRE[MAX_DATOS][32];
- new Float:VALOR[MAX_DATOS];
- new bool:EnTop[MAX_DATOS];
- //==============================================================================
- //Strings diálogos:
- new DLG_INFO_STR[2048];
- //Si se ponen más lugares en el top players,
- //modificar esto, máximo 4096:
- new DLG_TOP_PLY_STR[1024];
- //Si se ponen más lugares en el top clanes,
- //modificar esto, máximo 4096:
- new DLG_TOP_CLAN_STR[1024];
- //==============================================================================
- //JUGADORES:
- new bool:Registrado[MAX_PLAYERS] = false;
- new bool:Ingresado[MAX_PLAYERS] = false;
- new Nickname[MAX_PLAYERS][MAX_PLAYER_NAME];
- new Asesinatos[MAX_PLAYERS];
- new Muertes[MAX_PLAYERS];
- new Float:Ratio[MAX_PLAYERS];
- //Combinador de colores:
- new bool:CColor[MAX_PLAYERS] = false;
- new CSelec[MAX_PLAYERS] = 1;
- new COLORES[MAX_PLAYERS][4];//0 ROJO, 1 VERDE, 2 AZUL, 3 Transparencia
- //==============================================================================
- //TextDraws Combinador de colores
- new Text:NumColor[MAX_PLAYERS];
- new Text:Color[MAX_PLAYERS];
- new Text:CComb[MAX_PLAYERS];
- new Text:Comb[MAX_PLAYERS];
- //==============================================================================
- //CLANES:
- new Clan_TAG[MAX_PLAYERS][4];
- new Clan_ID[MAX_PLAYERS];
- new Invitacion[MAX_PLAYERS][32];
- new bool:EnClan[MAX_PLAYERS];
- //==============================================================================
- new PlayerColors[200] = {
- 0xFF8C13FF,0xC715FFFF,0x20B2AAFF,0xDC143CFF,0x6495EDFF,0xf0e68cFF,0x778899FF,
- 0xFF1493FF,0xF4A460FF,0xEE82EEFF,0xFFD720FF,0x8b4513FF,0x4949A0FF,0x148b8bFF,
- 0x14ff7fFF,0x556b2fFF,0x0FD9FAFF,0x10DC29FF,0x534081FF,0x0495CDFF,0xEF6CE8FF,
- 0xBD34DAFF,0x247C1BFF,0x0C8E5DFF,0x635B03FF,0xCB7ED3FF,0x65ADEBFF,0x5C1ACCFF,
- 0xF2F853FF,0x11F891FF,0x7B39AAFF,0x53EB10FF,0x54137DFF,0x275222FF,0xF09F5BFF,
- 0x3D0A4FFF,0x22F767FF,0xD63034FF,0x9A6980FF,0xDFB935FF,0x3793FAFF,0x90239DFF,
- 0xE9AB2FFF,0xAF2FF3FF,0x057F94FF,0xB98519FF,0x388EEAFF,0x028151FF,0xA55043FF,
- 0x0DE018FF,0x93AB1CFF,0x95BAF0FF,0x369976FF,0x18F71FFF,0x4B8987FF,0x491B9EFF,
- 0x829DC7FF,0xBCE635FF,0xCEA6DFFF,0x20D4ADFF,0x2D74FDFF,0x3C1C0DFF,0x12D6D4FF,
- 0x48C000FF,0x2A51E2FF,0xE3AC12FF,0xFC42A8FF,0x2FC827FF,0x1A30BFFF,0xB740C2FF,
- 0x42ACF5FF,0x2FD9DEFF,0xFAFB71FF,0x05D1CDFF,0xC471BDFF,0x94436EFF,0xC1F7ECFF,
- 0xCE79EEFF,0xBD1EF2FF,0x93B7E4FF,0x3214AAFF,0x184D3BFF,0xAE4B99FF,0x7E49D7FF,
- 0x4C436EFF,0xFA24CCFF,0xCE76BEFF,0xA04E0AFF,0x9F945CFF,0xDCDE3DFF,0x10C9C5FF,
- 0x70524DFF,0x0BE472FF,0x8A2CD7FF,0x6152C2FF,0xCF72A9FF,0xE59338FF,0xEEDC2DFF,
- 0xD8C762FF,0xD8C762FF,0xFF8C13FF,0xC715FFFF,0x20B2AAFF,0xDC143CFF,0x6495EDFF,
- 0xf0e68cFF,0x778899FF,0xFF1493FF,0xF4A460FF,0xEE82EEFF,0xFFD720FF,0x8b4513FF,
- 0x4949A0FF,0x148b8bFF,0x14ff7fFF,0x556b2fFF,0x0FD9FAFF,0x10DC29FF,0x534081FF,
- 0x0495CDFF,0xEF6CE8FF,0xBD34DAFF,0x247C1BFF,0x0C8E5DFF,0x635B03FF,0xCB7ED3FF,
- 0x65ADEBFF,0x5C1ACCFF,0xF2F853FF,0x11F891FF,0x7B39AAFF,0x53EB10FF,0x54137DFF,
- 0x275222FF,0xF09F5BFF,0x3D0A4FFF,0x22F767FF,0xD63034FF,0x9A6980FF,0xDFB935FF,
- 0x3793FAFF,0x90239DFF,0xE9AB2FFF,0xAF2FF3FF,0x057F94FF,0xB98519FF,0x388EEAFF,
- 0x028151FF,0xA55043FF,0x0DE018FF,0x93AB1CFF,0x95BAF0FF,0x369976FF,0x18F71FFF,
- 0x4B8987FF,0x491B9EFF,0x829DC7FF,0xBCE635FF,0xCEA6DFFF,0x20D4ADFF,0x2D74FDFF,
- 0x3C1C0DFF,0x12D6D4FF,0x48C000FF,0x2A51E2FF,0xE3AC12FF,0xFC42A8FF,0x2FC827FF,
- 0x1A30BFFF,0xB740C2FF,0x42ACF5FF,0x2FD9DEFF,0xFAFB71FF,0x05D1CDFF,0xC471BDFF,
- 0x94436EFF,0xC1F7ECFF,0xCE79EEFF,0xBD1EF2FF,0x93B7E4FF,0x3214AAFF,0x184D3BFF,
- 0xAE4B99FF,0x7E49D7FF,0x4C436EFF,0xFA24CCFF,0xCE76BEFF,0xA04E0AFF,0x9F945CFF,
- 0xDCDE3DFF,0x10C9C5FF,0x70524DFF,0x0BE472FF,0x8A2CD7FF,0x6152C2FF,0xCF72A9FF,
- 0xE59338FF,0xEEDC2DFF,0xD8C762FF,0xD8C762FF
- };
- public OnFilterScriptInit()
- {
- new
- Archivo[64];
- print("\n --------------------------------------");
- print(" Sistema & Tops 0.4.2");
- print(" --------------------------------------\n");
- SetTimer("ActualizarListaJugadores", 1500, 0);
- SetTimer("ActualizarTopPlayers", 3500, 0);
- SetTimer("ActualizarTopClanes", 5000, 0);
- format(Archivo, sizeof Archivo, "Clan.ini");
- if(!dini_Exists(Archivo)) {
- dini_Create(Archivo);
- dini_IntSet(Archivo, "Clan_IDs", 0);
- }
- if(!fexist("Jugadores.txt")) {
- new
- File:file = fopen("Jugadores.txt", io_write);
- fclose(file);
- }
- if(!fexist("Clanes.txt")) {
- new
- File:file = fopen("Clanes.txt", io_write);
- fclose(file);
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new
- Archivo[64];
- GetPlayerName(playerid, Nickname[playerid], MAX_PLAYER_NAME);
- if(strfind(Nickname[playerid], "[", true) != -1 || strfind(Nickname[playerid], "]", true) != -1)
- {
- SendClientMessage(playerid, ROJO, "Tu nick no puede contener corchetes");
- return Kick(playerid);
- }
- //Verificar registro:
- format(Archivo, sizeof(Archivo), "Jugadores/%s.ini", Nickname[playerid]);
- if(dini_Exists(Archivo)) Registrado[playerid] = true;
- SetPlayerColor(playerid, PlayerColors[playerid]);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- Invitacion[playerid][0] = 0;
- Clan_ID[playerid] = 0;
- Clan_TAG[playerid][0] = 0;
- EnClan[playerid] = false;
- Registrado[playerid] = false;
- Ingresado[playerid] = false;
- Asesinatos[playerid] = 0;
- Muertes[playerid] = 0;
- Ratio[playerid] = 0.0;
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- new
- Archivo[64],
- TempMuertes,
- TempAsesinatos;
- Muertes[playerid]++;
- Ratio[playerid] = float(Asesinatos[playerid]) / float(Muertes[playerid]);
- if(IsPlayerConnected(killerid) && killerid != INVALID_PLAYER_ID)
- {
- Asesinatos[killerid]++;
- if(Muertes[killerid] == 0) Ratio[killerid] = float(Asesinatos[playerid]);
- else Ratio[killerid] = float(Asesinatos[killerid]) / float(Muertes[killerid]);
- }
- if(IsPlayerConnected(playerid) && Ingresado[playerid] == true)
- {
- format(Archivo, sizeof(Archivo), "Jugadores/%s.ini", Nickname[playerid]);
- if(dini_Exists(Archivo))
- {
- dini_IntSet(Archivo, "Muertes", Muertes[playerid]);
- dini_FloatSet(Archivo, "Ratio", Ratio[playerid]);
- }
- if(EnClan[playerid] == true)
- {
- format(Archivo, sizeof Archivo, "Clanes/%s.ini", Clan_TAG[playerid]);
- if(dini_Exists(Archivo))
- {
- dini_IntSet(Archivo, "Muertes", dini_Int(Archivo, "Muertes")+1);
- dini_FloatSet(Archivo, "Ratio", float(dini_Int(Archivo, "Asesinatos")) / float(dini_Int(Archivo, "Muertes")));
- }
- }
- }
- if(IsPlayerConnected(killerid) && Ingresado[killerid] == true && killerid != INVALID_PLAYER_ID)
- {
- format(Archivo, sizeof(Archivo), "Jugadores/%s.ini", Nickname[killerid]);
- if(dini_Exists(Archivo))
- {
- dini_IntSet(Archivo, "Asesinatos", Asesinatos[killerid]);
- dini_FloatSet(Archivo, "Ratio", Ratio[killerid]);
- }
- if(EnClan[killerid] == true)
- {
- format(Archivo, sizeof Archivo, "Clanes/%s.ini", Clan_TAG[killerid]);
- if(dini_Exists(Archivo))
- {
- TempMuertes = dini_Int(Archivo, "Muertes");
- TempAsesinatos = dini_Int(Archivo, "Asesinatos");
- dini_IntSet(Archivo, "Asesinatos", TempAsesinatos+1);
- if(TempMuertes == 0) dini_FloatSet(Archivo, "Ratio", float(TempAsesinatos));
- else dini_FloatSet(Archivo, "Ratio", float(TempAsesinatos) / float(TempMuertes));
- }
- }
- }
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- new
- Nick[MAX_PLAYER_NAME],
- texto[128];
- if(text[0] == '!' && EnClan[playerid] == true)
- {
- GetPlayerName(playerid, Nick, MAX_PLAYER_NAME);
- format(texto, sizeof texto, "%s: %s", Nick, text[1]);
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(EnClan[i] == EnClan[playerid])
- {
- SendClientMessage(playerid, LIGHTBLUE, texto);
- }
- }
- }
- return 0;
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new
- cmd[20],
- tmp[20],
- tmp2[20],
- tmp3[24],
- string[64],
- Archivo[64],
- Nick[MAX_PLAYER_NAME],
- longitud,
- id,
- File:file,
- idx;
- cmd = strtok(cmdtext, idx);
- if(!strcmp("/kill", cmd, true))
- {
- SetPlayerHealth(playerid, 0.0);
- return 1;
- }
- if(!strcmp("/registrar", cmd, true))
- {
- if(Registrado[playerid] == true) return SendClientMessage(playerid, ROJO, "Ya estás registrado");
- tmp = strtok(cmdtext, idx);
- longitud = strlen(tmp);
- if(longitud == 0) return SendClientMessage(playerid, BLANCO, "Uso /registrar [Contraseña]");
- if(longitud < 3 || longitud > 16)
- {
- return SendClientMessage(playerid, ROJO, "La contraseña debe tener de 3 a 16 caracteres");
- }
- Registrar(playerid, tmp);
- return 1;
- }
- if(!strcmp("/login", cmd, true))
- {
- if(Registrado[playerid] == false) return SendClientMessage(playerid, ROJO, "No estás registrado");
- if(Ingresado[playerid] == true) return SendClientMessage(playerid, ROJO, "Ya estás logueado");
- tmp = strtok(cmdtext, idx);
- longitud = strlen(tmp);
- if(longitud == 0) return SendClientMessage(playerid, BLANCO, "Uso /login [Contraseña]");
- Login(playerid, tmp);
- return 1;
- }
- if(!strcmp(cmd, "/stats", true))
- {
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp)) return SendClientMessage(playerid, BLANCO, "Usa: /stats [id]");
- id = strval(tmp);
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid, ROJO, "Jugador no conectado");
- if(Ingresado[id] == false) return SendClientMessage(playerid, ROJO, "Ese jugador no está ingresado");
- format(Archivo, sizeof(Archivo), "Jugadores/%s.ini", Nickname[id]);
- format(DLG_INFO_STR, sizeof DLG_INFO_STR, "~.~");
- if(dini_Exists(Archivo))
- {
- format(DLG_INFO_STR, sizeof DLG_INFO_STR, "Asesinatos: %d\n", dini_Int(Archivo, "Asesinatos"));
- format(DLG_INFO_STR, sizeof DLG_INFO_STR, "%sMuertes: %d\n", DLG_INFO_STR, dini_Int(Archivo, "Muertes"));
- format(DLG_INFO_STR, sizeof DLG_INFO_STR, "%sRatio: %d\n", DLG_INFO_STR, dini_Float(Archivo, "Ratio"));
- format(DLG_INFO_STR, sizeof DLG_INFO_STR, "%sClan: [%s]", DLG_INFO_STR, dini_Get(Archivo, "Clan"));
- }
- format(string, sizeof string, "Stadísticas de %s (%d)", Nickname[id], id);
- ShowPlayerDialog(playerid, DLG_PLY_INFO, DIALOG_STYLE_MSGBOX, string, DLG_INFO_STR, "Aceptar", "Cancelar");
- return 1;
- }
- if(!strcmp(cmd, "/Topplayers", true))
- {
- ShowPlayerDialog(playerid, DLG_TOP_PLAYERS, DIALOG_STYLE_LIST, "Top Players", DLG_TOP_PLY_STR, "Aceptar", "Cancelar");
- return 1;
- }
- if(!strcmp(cmd, "/Topclanes", true))
- {
- ShowPlayerDialog(playerid, DLG_TOP_CLANES, DIALOG_STYLE_LIST, "Top Clanes", DLG_TOP_CLAN_STR, "Aceptar", "Cancelar");
- return 1;
- }
- if(!strcmp(cmd, "/clan", true))
- {
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp)) return SendClientMessage(playerid, BLANCO, "Usa: /clan [info, crear, invitar, entrar, salir, expulsar, color, colorh] [TAG] [Nombre]");
- if(!strcmp(tmp, "crear", true))
- {
- if(Ingresado[id] == false) return SendClientMessage(playerid, ROJO, "Necesitas estar logueado para usar este comando");
- if(EnClan[playerid] == true) return SendClientMessage(playerid, ROJO, "Ya tienes clan");
- tmp2 = strtok(cmdtext, idx);
- tmp3 = strrest(cmdtext, idx);
- if(!strlen(tmp2) || !strlen(tmp3)) return SendClientMessage(playerid, BLANCO, "Usa: /clan crear [TAG] [Nombre]");
- if(strlen(tmp2) < 1 || strlen(tmp2) > 3) return SendClientMessage(playerid, ROJO, "Sólo de 1 a 3 caracteres");
- if(strlen(tmp3) < 3 || strlen(tmp3) > 24) return SendClientMessage(playerid, ROJO, "Sólo de 3 a 24 caracteres");
- if(strfind(tmp2, "[", true) != -1 || strfind(tmp2, "]", true) != -1)
- {
- return SendClientMessage(playerid, ROJO, "Sin '[' ']' (corchetes) .");
- }
- format(Archivo, sizeof Archivo, "Clanes/%s.ini", tmp2);
- if(!dini_Exists(Archivo))
- {
- format(Clan_TAG[playerid], 4, "%s", tmp2);
- Clan_ID[playerid] = dini_Int("Clan.ini", "Clan_IDs")+1;
- dini_IntSet("Clan.ini", "Clan_IDs", Clan_ID[playerid]);
- dini_Create(Archivo);
- dini_IntSet(Archivo, "ID", Clan_ID[playerid]);
- dini_Set(Archivo, "Nombre", tmp3);
- dini_Set(Archivo, "TAG", tmp2);
- dini_IntSet(Archivo, "Color", id);
- dini_Set(Archivo, "Lider", Nickname[playerid]);
- dini_IntSet(Archivo, "Miembros", 1);
- dini_IntSet(Archivo, "Asesinatos", 0);
- dini_IntSet(Archivo, "Muertes", 0);
- dini_FloatSet(Archivo, "Ratio", 0.0);
- dini_Set(Archivo, "Miembro_1", Nickname[playerid]);
- for(new l = 2; l < 21; l++)
- {
- format(string, sizeof string, "Miembro_%d", l);
- dini_Set(Archivo, string, "<Vacio>");
- }
- format(Archivo, sizeof Archivo, "Jugadores/%s.ini", Nickname[playerid]);
- dini_Set(Archivo, "Clan", Clan_TAG[playerid]);
- file = fopen("Clanes.txt", io_append);
- format(string, sizeof(string), "%s;\r\n", Clan_TAG[playerid]);
- fwrite(file, string);
- fclose(file);
- format(Nick, sizeof Nick, "[%s]%s", Clan_TAG[playerid], Nickname[playerid]);
- SetPlayerName(playerid, Nick);
- SetPlayerColor(playerid, 0);
- EnClan[playerid] = true;
- format(string, sizeof string, "Has creado el clan '%s' TAG: [%s]", tmp3, tmp2);
- SendClientMessage(playerid, LIGHTBLUE, string);
- SendClientMessage(playerid, NARANJA, "Usa /clan color/colorh para cambiar el color de tu clan");
- } else {
- SendClientMessage(playerid, ROJO, "El TAG ya está en uso");
- }
- return 1;
- }
- if(!strcmp(tmp, "color", true))
- {
- if(EnClan[playerid] == false) return SendClientMessage(playerid, ROJO, "No tienes clan");
- format(Archivo, sizeof Archivo, "Clanes/%s.ini", Clan_TAG[playerid]);
- if(strcmp(dini_Get(Archivo, "Lider"), Nickname[playerid]) != 0)
- return SendClientMessage(playerid, ROJO, "Necesitas ser el creador del clan para poder cambiar el color");
- if(CColor[playerid] == true) {
- OcultarCombinador(playerid);
- TogglePlayerControllable(playerid, 1);
- CColor[playerid] = false;
- } else {
- MostrarCombinador(playerid);
- TogglePlayerControllable(playerid, 0);
- COLORES[playerid][3] = 255;
- CColor[playerid] = true;
- SendClientMessage(playerid, NICESKY, "Usa /clan color para cancelar");
- GameTextForPlayer(playerid, "~h~Usa ~<~, ~>~, ~u~, ~d~ y ~k~~PED_SPRINT~ ~n~para cambiar el color y ~k~~PED_FIREWEAPON~ ~n~para seleccionar", 100000, 3);
- }
- return 1;
- }
- if(!strcmp(tmp, "colorh", true))
- {
- if(EnClan[playerid] == false) return SendClientMessage(playerid, ROJO, "No tienes clan");
- if(strcmp(dini_Get(Archivo, "Lider"), Nickname[playerid]) != 0)
- return SendClientMessage(playerid, ROJO, "Necesitas ser el creador del clan para poder cambiar el color");
- if(CColor[playerid] == true) return SendClientMessage(playerid, ROJO, "Cierra primero el combinador de colores.");
- tmp2 = strtok(cmdtext, idx);
- longitud = strlen(tmp2);
- if(!longitud) return SendClientMessage(playerid, BLANCO, "Usa: /clan colorh [Código Hexadecimal]");
- if(longitud > 10) return SendClientMessage(playerid, ROJO, "Demasiado grande");
- new
- rojo[3] = "00",
- azul[3] = "00",
- verde[3] = "00",
- alfa[3],
- ColorC;
- if(tmp2[0] == '#')
- {
- format(string, sizeof string, "%s", tmp2[1]);
- if(!IsAHexNumber(string)) return SendClientMessage(playerid, ROJO, "Formato incorrecto. Ejemplo: #FFFFFFFF");
- format(rojo, sizeof rojo, "%c%c", tmp2[1], tmp2[2]);
- format(azul, sizeof azul, "%c%c", tmp2[3], tmp2[4]);
- format(verde, sizeof verde, "%c%c", tmp2[5], tmp2[6]);
- if(tmp2[7] != '\0')
- format(alfa, sizeof alfa, "%c%c", tmp2[7], tmp2[8]);
- else alfa = "FF";
- ColorC = RGBA(HexToInt(rojo), HexToInt(verde), HexToInt(azul), HexToInt(alfa));
- format(Archivo, sizeof Archivo, "Clanes/%s.ini", Clan_TAG[playerid]);
- dini_IntSet(Archivo, "Color", ColorC);
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- if(Clan_ID[playerid] == Clan_ID[i])
- SetPlayerColor(i, ColorC);
- }
- format(string, sizeof string, "~y~~h~ Color seleccionado~n~~p~#%s%s%s%s", rojo, verde, azul, alfa);
- GameTextForPlayer(playerid, string, 3000, 4);
- return 1;
- }
- else if(tmp2[0] == '0' && tmp2[1] == 'x')
- {
- format(string, sizeof string, "%s", tmp2[2]);
- if(!IsAHexNumber(string)) return SendClientMessage(playerid, ROJO, "Formato incorrecto. Ejemplo: 0xFFFFFFFF");
- format(rojo, sizeof rojo, "%c%c", tmp2[2], tmp2[3]);
- format(azul, sizeof azul, "%c%c", tmp2[4], tmp2[5]);
- format(verde, sizeof verde, "%c%c", tmp2[6], tmp2[7]);
- if(tmp2[8] != '\0')
- format(alfa, sizeof alfa, "%c%c", tmp2[8], tmp2[9]);
- else alfa = "FF";
- ColorC = RGBA(HexToInt(rojo), HexToInt(verde), HexToInt(azul), HexToInt(alfa));
- format(Archivo, sizeof Archivo, "Clanes/%s.ini", Clan_TAG[playerid]);
- dini_IntSet(Archivo, "Color", ColorC);
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- if(Clan_ID[playerid] == Clan_ID[i])
- SetPlayerColor(i, ColorC);
- }
- format(string, sizeof string, "~y~~h~ Color seleccionado~n~~p~0x%s%s%s%s", rojo, verde, azul, alfa);
- GameTextForPlayer(playerid, string, 3000, 4);
- return 1;
- }
- if(IsAHexNumber(tmp2))
- {
- format(rojo, sizeof rojo, "%c%c", tmp2[0], tmp2[1]);
- format(azul, sizeof azul, "%c%c", tmp2[2], tmp2[3]);
- format(verde, sizeof verde, "%c%c", tmp2[4], tmp2[5]);
- if(tmp2[6] != '\0')
- format(alfa, sizeof alfa, "%c%c", tmp2[6], tmp2[7]);
- else alfa = "FF";
- ColorC = RGBA(HexToInt(rojo), HexToInt(verde), HexToInt(azul), HexToInt(alfa));
- format(Archivo, sizeof Archivo, "Clanes/%s.ini", Clan_TAG[playerid]);
- dini_IntSet(Archivo, "Color", ColorC);
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- if(Clan_ID[playerid] == Clan_ID[i])
- SetPlayerColor(i, ColorC);
- }
- format(string, sizeof string, "~y~~h~ Color seleccionado~n~~p~%s%s%s%s", rojo, verde, azul, alfa);
- GameTextForPlayer(playerid, string, 3000, 4);
- return 1;
- } else return SendClientMessage(playerid, ROJO, "Formato incorrecto. Ejemplo: FFFFFFFF");
- }
- if(!strcmp(tmp, "invitar", true))
- {
- if(EnClan[playerid] == false) return SendClientMessage(playerid, ROJO, "No tienes clan");
- if(!strlen(tmp2)) return SendClientMessage(playerid, BLANCO, "Usa: /clan invitar [id]");
- tmp2 = strtok(cmdtext, idx);
- id = strval(tmp2);
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid, ROJO, "Jugador no conectado");
- if(Ingresado[id] == false) return SendClientMessage(playerid, ROJO, "El jugador invitado necesita estar logueado");
- if(id == playerid) return SendClientMessage(playerid, ROJO, "No puedes enviarte invitación a ti mismo");
- format(Archivo, sizeof Archivo, "Clanes/%s.ini", Clan_TAG[playerid]);
- if(strcmp(dini_Get(Archivo, "Lider"), Nickname[playerid]) != 0)
- return SendClientMessage(playerid, ROJO, "Necesitas ser el creador del clan para poder invitar");
- if(EnClan[id] == true) return SendClientMessage(playerid, ROJO, "Ese jugador ya tiene clan");
- format(string, sizeof string, "* %s te ha invitado al clan '%s'", Nickname[playerid], dini_Get(Archivo, "Nombre"));
- SendClientMessage(id, LIGHTBLUE, string);
- SendClientMessage(id, NARANJA, "Usa /clan entrar para aceptar la invitación o /clan rechazar para rechazar la invitación.");
- format(string, sizeof string, "* Has invitado a %s ", Nickname[id]);
- SendClientMessage(playerid, LIGHTBLUE, string);
- format(Invitacion[id], 4, "%s", Clan_TAG[playerid]);
- return 1;
- }
- if(!strcmp(tmp, "rechazar", true))
- {
- if(!strlen(Invitacion[playerid])) return SendClientMessage(playerid, ROJO, "No te han invitado a ningun clan");
- Invitacion[playerid][0] = 0;
- return 1;
- }
- if(!strcmp(tmp, "entrar", true))
- {
- if(!strlen(Invitacion[playerid])) return SendClientMessage(playerid, ROJO, "No te han invitado a ningun clan");
- if(EnClan[playerid] == true) return SendClientMessage(playerid, ROJO, "Ya tienes clan");
- format(Archivo, sizeof Archivo, "Clanes/%s.ini", Invitacion[playerid]);
- if(dini_Exists(Archivo))
- {
- new
- IDMiembro = 2;
- if(dini_Int(Archivo, "Miembros") == 20) return SendClientMessage(playerid, ROJO, "El clan está lleno");
- dini_IntSet(Archivo, "Miembros", dini_Int(Archivo, "Miembros")+1);
- while(IDMiembro < 20)
- {
- format(string, sizeof string, "Miembro_%d", IDMiembro);
- if(!strcmp(dini_Get(Archivo, string), "<Vacio>"))
- {
- dini_Set(Archivo, string, Nickname[playerid]);
- break;
- }
- IDMiembro++;
- }
- format(Clan_TAG[playerid], 4, Invitacion[playerid]);
- format(Archivo, sizeof Archivo, "Jugadores/%s.ini", Nickname[playerid]);
- dini_Set(Archivo, "Clan", Clan_TAG[playerid]);
- format(Nick, sizeof Nick, "[%s]%s", Clan_TAG[playerid], Nickname[playerid]);
- SetPlayerName(playerid, Nick);
- SetPlayerColor(playerid, dini_Int(Archivo, "Color"));
- format(string, sizeof string, "* %s has entrado al clan '%s'", dini_Get(Archivo, "Nombre"));
- SendClientMessage(playerid, BLANCO, string);
- Clan_ID[playerid] = dini_Int(Archivo, "ID");
- format(string, sizeof string, "* %s ha entrado al clan ", Nickname[playerid]);
- for(new i = 0; i < MAX_PLAYERS; i++) {
- if(i == playerid || !IsPlayerConnected(i)) continue;
- if(Clan_ID[playerid] == Clan_ID[i]) SendClientMessage(i, BLANCO, string);
- }
- EnClan[playerid] = true;
- } else return SendClientMessage(playerid, ROJO, "Ya no existe ese clan");
- return 1;
- }
- if(!strcmp(tmp, "salir", true))
- {
- if(EnClan[playerid] == false) return SendClientMessage(playerid, ROJO, "No tienes clan");
- format(string, sizeof string, "* %s ha salido del clan", Nickname[playerid]);
- for(new i = 0; i < MAX_PLAYERS; i++) {
- if(i == playerid || !IsPlayerConnected(i)) continue;
- if(Clan_ID[playerid] == Clan_ID[i]) SendClientMessage(i, BLANCO, string);
- }
- Clan_ID[playerid] = 0;
- format(Archivo, sizeof Archivo, "Clanes/%s.ini", Clan_TAG[playerid]);
- file = fopen(Archivo, io_read);
- while(fread(file, string))
- {
- idx = strfind(string, Nickname[playerid], true);
- if(idx != -1)
- {
- strmid(string, string, 0, idx-1, 16);
- dini_Set(Archivo, string, "<Vacio>");
- }
- }
- fclose(file);
- dini_IntSet(Archivo, "Miembros", dini_Int(Archivo, "Miembros")-1);
- format(string, sizeof string, "* Saliste del clan '%s'", dini_Get(Archivo, "Nombre"));
- SendClientMessage(playerid, ROJO, string);
- if(dini_Int(Archivo, "Miembros") == 0)
- {
- new
- Linea = 0,
- str[16];
- dini_Remove(Archivo);
- file = fopen("Clanes.txt", io_read);
- format(str, sizeof str, "%s;", Clan_TAG[playerid]);
- while(fread(file, string))
- {
- Linea++;
- if(strfind(string, str, true) == 0)
- {
- DeleteLine("Clanes.txt", Linea);
- break;
- }
- }
- fclose(file);
- format(string, sizeof string, "Tu clan con el TAG '%s' ha sido borrado por falta de miembros", Clan_TAG[playerid]);
- SendClientMessage(playerid, ROJO, string);
- }
- format(Archivo, sizeof Archivo, "Jugadores/%s.ini", Nickname[playerid]);
- dini_Set(Archivo, "Clan", "<Ninguno>");
- SetPlayerName(playerid, Nickname[playerid]);
- SetPlayerColor(playerid, PlayerColors[playerid]);
- Clan_TAG[playerid][0] = 0;
- EnClan[playerid] = false;
- return 1;
- }
- if(!strcmp(tmp, "expulsar", true))
- {
- if(EnClan[playerid] == false) return SendClientMessage(playerid, ROJO, "No tienes clan");
- tmp2 = strtok(cmdtext, idx);
- if(!strlen(tmp2)) return SendClientMessage(playerid, BLANCO, "Usa: /clan expulsar [id]");
- id = strval(tmp2);
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid, ROJO, "Jugador no conectado");
- if(id == playerid) return SendClientMessage(playerid, ROJO, "No puedes expulsarte a ti mismo");
- format(Archivo, sizeof Archivo, "Clanes/%s.ini", Clan_TAG[playerid]);
- if(Clan_ID[playerid] != Clan_ID[id]) return SendClientMessage(playerid, ROJO, "Ese jugador no está en tu clan");
- if(strcmp(dini_Get(Archivo, "Lider"), Nickname[playerid]) != 0)
- return SendClientMessage(playerid, ROJO, "Necesitas ser el creador del clan para poder expulsar");
- OnPlayerCommandText(playerid, "/clan salir");
- SendClientMessage(playerid, ROJO, "Fuiste expulsado del clan");
- return 1;
- }
- if(!strcmp(tmp, "info", true))
- {
- tmp2 = strtok(cmdtext, idx);
- if(!strlen(tmp2)) return SendClientMessage(playerid, BLANCO, "Usa: /clan info [TAG]");
- format(Archivo, sizeof Archivo, "Clanes/%s.ini", tmp2);
- if(dini_Exists(Archivo))
- {
- format(DLG_INFO_STR, sizeof DLG_INFO_STR, "> ID: %d\n", dini_Int(Archivo, "ID"));
- format(DLG_INFO_STR, sizeof DLG_INFO_STR, "%s> Color: %d\n", DLG_INFO_STR, dini_Int(Archivo, "Color"));
- format(DLG_INFO_STR, sizeof DLG_INFO_STR, "%s> Líder: %s\n", DLG_INFO_STR, dini_Get(Archivo, "Lider"));
- format(DLG_INFO_STR, sizeof DLG_INFO_STR, "%s> Miembros: %d\n", DLG_INFO_STR, dini_Int(Archivo, "Miembros"));
- format(DLG_INFO_STR, sizeof DLG_INFO_STR, "%s> Asesinatos: %d\n", DLG_INFO_STR, dini_Int(Archivo, "Asesinatos"));
- format(DLG_INFO_STR, sizeof DLG_INFO_STR, "%s> Muertes: %d\n", DLG_INFO_STR, dini_Int(Archivo, "Muertes"));
- format(DLG_INFO_STR, sizeof DLG_INFO_STR, "%s> Ratio: %0.0f\n", DLG_INFO_STR, dini_Float(Archivo, "Ratio"));
- for(new d = 1; d < 21; d++)
- {
- format(string, sizeof string, "Miembro_%d", d);
- format(DLG_INFO_STR, sizeof DLG_INFO_STR, "%s> Miembro %d: %s\n", DLG_INFO_STR, d, dini_Get(Archivo, string));
- }
- format(string, sizeof string, "Información '%s' [%s]", dini_Get(Archivo, "Nombre"), dini_Get(Archivo, "TAG"));
- ShowPlayerDialog(playerid, DLG_CLAN_INFO, DIALOG_STYLE_MSGBOX, string, DLG_INFO_STR, "Aceptar", "Cancelar");
- } else return SendClientMessage(playerid, ROJO, "No existe ese clan");
- return 1;
- }
- return 1;
- }
- return 0;
- }
- public OnPlayerUpdate(playerid)
- {
- if(CColor[playerid] == true)
- {
- new
- keys,
- updown,
- leftright,
- Archivo[64];
- GetPlayerKeys(playerid, keys, updown, leftright);
- if(updown < 0) CSelec[playerid]--;//ARRIBA
- else if(updown > 0) CSelec[playerid]++;//ABAJO
- if(CSelec[playerid] > 4) CSelec[playerid] = 1;
- else if(CSelec[playerid] < 1) CSelec[playerid] = 4;
- if(keys & KEY_FIRE)
- {
- new
- ColorC = RGBA(COLORES[playerid][0], COLORES[playerid][1], COLORES[playerid][2], COLORES[playerid][3]);
- format(Archivo, sizeof Archivo, "Clanes/%s.ini", Clan_TAG[playerid]);
- dini_IntSet(Archivo, "Color", ColorC);
- CColor[playerid] = false;
- COLORES[playerid][0] = 0;//ROJO
- COLORES[playerid][1] = 0;//VERDE
- COLORES[playerid][2] = 0;//AZUL
- COLORES[playerid][3] = 255;//ALPHA
- SetTimerEx("OcultarCombinador", 500, 0, "i", playerid);
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- if(Clan_ID[playerid] == Clan_ID[i])
- SetPlayerColor(i, ColorC);
- }
- TogglePlayerControllable(playerid, 1);
- GameTextForPlayer(playerid, "~y~~h~ Color seleccionado", 3000, 4);
- }
- if(leftright > 0)//DERECHA
- {
- if(CSelec[playerid] == 1)//ROJO
- {
- if(keys & KEY_SPRINT) COLORES[playerid][0] += 5;
- else COLORES[playerid][0]++;
- if(COLORES[playerid][0] > 255) COLORES[playerid][0] = 0;
- }
- if(CSelec[playerid] == 2)//VERDE
- {
- if(keys & KEY_SPRINT) COLORES[playerid][1] += 5;
- else COLORES[playerid][1]++;
- if(COLORES[playerid][1] > 255) COLORES[playerid][1] = 0;
- }
- if(CSelec[playerid] == 3)//AZUL
- {
- if(keys & KEY_SPRINT) COLORES[playerid][2] += 5;
- else COLORES[playerid][2]++;
- if(COLORES[playerid][2] > 255) COLORES[playerid][2] = 0;
- }
- if(CSelec[playerid] == 4)//ALPHA
- {
- if(keys & KEY_SPRINT) COLORES[playerid][3] += 5;
- else COLORES[playerid][3]++;
- if(COLORES[playerid][3] > 255) COLORES[playerid][3] = 0;
- }
- }
- if(leftright < 0)//IZQUIERDA
- {
- if(CSelec[playerid] == 1)//ROJO
- {
- if(keys & KEY_SPRINT) COLORES[playerid][0] -= 5;
- else COLORES[playerid][0]--;
- if(COLORES[playerid][0] < 0) COLORES[playerid][0] = 255;
- }
- if(CSelec[playerid] == 2)//VERDE
- {
- if(keys & KEY_SPRINT) COLORES[playerid][1] -= 5;
- else COLORES[playerid][1]--;
- if(COLORES[playerid][1] < 0) COLORES[playerid][1] = 255;
- }
- if(CSelec[playerid] == 3)//AZUL
- {
- if(keys & KEY_SPRINT) COLORES[playerid][2] -= 5;
- else COLORES[playerid][2]--;
- if(COLORES[playerid][2] < 0) COLORES[playerid][2] = 255;
- }
- if(CSelec[playerid] == 4)//ALHPA
- {
- if(keys & KEY_SPRINT) COLORES[playerid][3] -= 5;
- else COLORES[playerid][3]--;
- if(COLORES[playerid][3] < 0) COLORES[playerid][3] = 255;
- }
- }
- ActualizarCombinador(playerid);
- }
- return 1;
- }
- forward ActualizarCombinador(playerid);
- public ActualizarCombinador(playerid)
- {
- new
- str[128],
- ColorS = RGBA(COLORES[playerid][0], COLORES[playerid][1], COLORES[playerid][2], COLORES[playerid][3]);
- if(CSelec[playerid] == 1) {
- format(str, sizeof str, "~w~>~r~ ROJO ~<~ %03d ~>~ ~n~~g~ VERDE ~<~ %03d ~>~ ~n~~b~ AZUL ~<~ %03d ~>~ ~n~~w~ ALPHA ~<~ %03d ~>~",
- COLORES[playerid][0], COLORES[playerid][1], COLORES[playerid][2], COLORES[playerid][3]);
- }
- if(CSelec[playerid] == 2) {
- format(str, sizeof str, "~r~ ROJO ~<~ %03d ~>~ ~n~~w~>~g~ VERDE ~<~ %03d ~>~ ~n~~b~ AZUL ~<~ %03d ~>~ ~n~~w~ ALPHA ~<~ %03d ~>~",
- COLORES[playerid][0], COLORES[playerid][1], COLORES[playerid][2], COLORES[playerid][3]);
- }
- if(CSelec[playerid] == 3) {
- format(str, sizeof str, "~r~ ROJO ~<~ %03d ~>~ ~n~~g~ VERDE ~<~ %03d ~>~ ~n~~w~>~b~ AZUL ~<~ %03d ~>~ ~n~~w~ ALPHA ~<~ %03d ~>~",
- COLORES[playerid][0], COLORES[playerid][1], COLORES[playerid][2], COLORES[playerid][3]);
- }
- if(CSelec[playerid] == 4) {
- format(str, sizeof str, "~r~ ROJO ~<~ %03d ~>~ ~n~~g~ VERDE ~<~ %03d ~>~ ~n~~b~ AZUL ~<~ %03d ~>~ ~n~~w~>~w~ ALPHA ~<~ %03d ~>~",
- COLORES[playerid][0], COLORES[playerid][1], COLORES[playerid][2], COLORES[playerid][3]);
- }
- TextDrawSetString(Comb[playerid], str);
- format(str, sizeof str, "~y~0x%x%x%x%x", COLORES[playerid][0], COLORES[playerid][1], COLORES[playerid][2], COLORES[playerid][3]);
- TextDrawSetString(NumColor[playerid], str);
- TextDrawHideForPlayer(playerid, Color[playerid]);
- TextDrawDestroy(Color[playerid]);
- Color[playerid] = TextDrawCreate(9.000000, 255.000000, "CAJA");
- TextDrawBackgroundColor(Color[playerid], 0);
- TextDrawFont(Color[playerid], 1);
- TextDrawLetterSize(Color[playerid], 1.630000, 2.099999);
- TextDrawColor(Color[playerid], 0);
- TextDrawSetProportional(Color[playerid], 1);
- TextDrawUseBox(Color[playerid], 1);
- TextDrawBoxColor(Color[playerid], ColorS);
- TextDrawTextSize(Color[playerid], 153.000000, 0.000000);
- TextDrawShowForPlayer(playerid, Color[playerid]);
- }
- forward MostrarCombinador(playerid);
- public MostrarCombinador(playerid)
- {
- NumColor[playerid] = TextDrawCreate(9.000000, 237.000000, "~y~0x00000000");
- TextDrawBackgroundColor(NumColor[playerid], 255);
- TextDrawFont(NumColor[playerid], 1);
- TextDrawLetterSize(NumColor[playerid], 0.500000, 1.000000);
- TextDrawColor(NumColor[playerid], -1);
- TextDrawSetOutline(NumColor[playerid], 0);
- TextDrawSetProportional(NumColor[playerid], 1);
- TextDrawSetShadow(NumColor[playerid], 1);
- TextDrawUseBox(NumColor[playerid], 1);
- TextDrawBoxColor(NumColor[playerid], 1684300900);
- TextDrawTextSize(NumColor[playerid], 153.000000, 0.000000);
- Color[playerid] = TextDrawCreate(9.000000, 255.000000, "CAJA");
- TextDrawBackgroundColor(Color[playerid], 0);
- TextDrawFont(Color[playerid], 1);
- TextDrawLetterSize(Color[playerid], 1.630000, 2.099999);
- TextDrawColor(Color[playerid], 0);
- TextDrawSetProportional(Color[playerid], 1);
- TextDrawUseBox(Color[playerid], 1);
- TextDrawBoxColor(Color[playerid], 0);
- TextDrawTextSize(Color[playerid], 153.000000, 0.000000);
- CComb[playerid] = TextDrawCreate(9.000000, 283.000000, "CAJA");
- TextDrawBackgroundColor(CComb[playerid], 0);
- TextDrawFont(CComb[playerid], 1);
- TextDrawLetterSize(CComb[playerid], 1.630000, 5.100001);
- TextDrawColor(CComb[playerid], 0);
- TextDrawSetOutline(CComb[playerid], 0);
- TextDrawSetProportional(CComb[playerid], 1);
- TextDrawSetShadow(CComb[playerid], 1);
- TextDrawUseBox(CComb[playerid], 1);
- TextDrawBoxColor(CComb[playerid], 1684300900);
- TextDrawTextSize(CComb[playerid], 153.000000, 0.000000);
- Comb[playerid] = TextDrawCreate(9.000000, 280.000000, "~r~ ROJO ~<~ 255 ~>~ ~n~~g~ VERDE ~<~ 255 ~>~ ~n~~b~ AZUL ~<~ 255 ~>~ ~n~~w~ ALPHA ~<~ 255 ~>~");
- TextDrawBackgroundColor(Comb[playerid], 255);
- TextDrawFont(Comb[playerid], 2);
- TextDrawLetterSize(Comb[playerid], 0.400000, 1.400000);
- TextDrawColor(Comb[playerid], -1);
- TextDrawSetOutline(Comb[playerid], 0);
- TextDrawSetProportional(Comb[playerid], 1);
- TextDrawSetShadow(Comb[playerid], 1);
- TextDrawShowForPlayer(playerid, NumColor[playerid]);
- TextDrawShowForPlayer(playerid, Color[playerid]);
- TextDrawShowForPlayer(playerid, CComb[playerid]);
- TextDrawShowForPlayer(playerid, Comb[playerid]);
- }
- forward OcultarCombinador(playerid);
- public OcultarCombinador(playerid)
- {
- TextDrawHideForPlayer(playerid, NumColor[playerid]);
- TextDrawHideForPlayer(playerid, Color[playerid]);
- TextDrawHideForPlayer(playerid, CComb[playerid]);
- TextDrawHideForPlayer(playerid, Comb[playerid]);
- TextDrawDestroy(NumColor[playerid]);
- TextDrawDestroy(Color[playerid]);
- TextDrawDestroy(CComb[playerid]);
- TextDrawDestroy(Comb[playerid]);
- }
- forward ActualizarListaJugadores();
- public ActualizarListaJugadores()
- {
- new
- File:file,
- bool:Existe = false,
- string[128],
- str[32];
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(Ingresado[i] == true)
- {
- format(str, sizeof(str), "%s;", Nickname[i]);
- file = fopen("Jugadores.txt", io_read);
- while(fread(file, string))
- {
- if(strfind(string, str, true) == 0)
- {
- Existe = true;
- }
- }
- fclose(file);
- if(Existe == false)
- {
- file = fopen("Jugadores.txt", io_append);
- format(string, sizeof(string), "%s;\r\n", Nickname[i]);
- fwrite(file, string);
- fclose(file);
- }
- }
- }
- Existe = false;
- }
- }
- forward ActualizarTopClanes();
- public ActualizarTopClanes()
- {
- new
- File:file,
- Archivo[64],
- string[128],
- Linea,
- Lugar,
- Float:MAX_VALOR = -1.0;
- //EXTRAER DATOS DEL ARCHIVO "Clanes.txt"
- file = fopen("Clanes.txt", io_read);
- while(fread(file, string))
- {
- new
- v = strfind(string, ";", true);
- strmid(NOMBRE[Linea], string, 0, v, 24);
- format(Archivo, sizeof Archivo, "Clanes/%s.ini", NOMBRE[Linea]);
- if(dini_Exists(Archivo))
- {
- VALOR[Linea] = dini_Float(Archivo, "Ratio");
- }
- Linea++;
- }
- fclose(file);
- //SACAR LUGARES Y GUARDARLOS
- Lugar = 1;
- while(Lugar < MAX_TOP_CLANES+1)
- {
- for(new i = 0; i < MAX_DATOS; i++)
- {
- if(EnTop[i] == false)
- {
- if(VALOR[i] > MAX_VALOR)
- {
- MAX_VALOR = VALOR[i];
- TopC[Lugar] = i;
- }
- }
- }
- strmid(TopInfoC[Lugar][NickTOP], NOMBRE[TopC[Lugar]], 0, strlen(NOMBRE[TopC[Lugar]]), 24);
- format(Archivo, sizeof Archivo, "Clanes/%s.ini", TopInfoC[Lugar][NickTOP]);
- TopInfoC[Lugar][AsesinatosTOP] = dini_Int(Archivo, "Asesinatos");
- TopInfoC[Lugar][MuertesTOP] = dini_Int(Archivo, "Muertes");
- TopInfoC[Lugar][RatioTOP] = dini_Float(Archivo, "Ratio");
- EnTop[TopC[Lugar]] = true;
- MAX_VALOR = -1;
- Lugar++;
- }
- //RESETEAR DATOS:
- for(new s = 0; s < MAX_DATOS; s++)
- {
- EnTop[s] = false;
- NOMBRE[s][0] = 0;
- VALOR[s] = 0.0;
- }
- //GUARDAR DATOS EN UNA CADENA DE CARACTERES
- format(DLG_TOP_CLAN_STR, sizeof DLG_TOP_CLAN_STR, "");
- Lugar = 1;
- while(Lugar < MAX_TOP_CLANES+1)
- {
- format(DLG_TOP_CLAN_STR, sizeof DLG_TOP_CLAN_STR,
- "%s| %02d | %s | Asesinatos: %d | Muertes: %d | Ratio: %0.0f|\n",
- DLG_TOP_CLAN_STR, Lugar, TopInfoC[Lugar][NickTOP], TopInfoC[Lugar][AsesinatosTOP],
- TopInfoC[Lugar][MuertesTOP], TopInfoC[Lugar][RatioTOP]);
- Lugar++;
- }
- SetTimer("ActualizarTopClanes", 62000, 0);
- }
- forward ActualizarTopPlayers();
- public ActualizarTopPlayers()
- {
- new
- File:file,
- Archivo[64],
- string[128],
- Linea,
- Lugar,
- Float:MAX_VALOR = -1.0;
- //EXTRAER DATOS DEL ARCHIVO "Jugadores.txt"
- file = fopen("Jugadores.txt", io_read);
- while(fread(file, string))
- {
- new
- v = strfind(string, ";", true);
- strmid(NOMBRE[Linea], string, 0, v, 24);
- format(Archivo, sizeof(Archivo), "Jugadores/%s.ini", NOMBRE[Linea]);
- if(dini_Exists(Archivo))
- {
- VALOR[Linea] = dini_Float(Archivo, "Ratio");
- }
- Linea++;
- }
- fclose(file);
- //SACAR LUGARES Y GUARDARLOS
- Lugar = 1;
- while(Lugar < MAX_TOP_PLAYERS+1)
- {
- for(new i = 0; i < MAX_DATOS; i++)
- {
- if(EnTop[i] == false)
- {
- if(VALOR[i] > MAX_VALOR)
- {
- MAX_VALOR = VALOR[i];
- TopP[Lugar] = i;
- }
- }
- }
- strmid(TopInfoP[Lugar][NickTOP], NOMBRE[TopP[Lugar]], 0, strlen(NOMBRE[TopP[Lugar]]), 24);
- format(Archivo, sizeof(Archivo), "Jugadores/%s.ini", TopInfoP[Lugar][NickTOP]);
- TopInfoP[Lugar][AsesinatosTOP] = dini_Int(Archivo, "Asesinatos");
- TopInfoP[Lugar][MuertesTOP] = dini_Int(Archivo, "Muertes");
- TopInfoP[Lugar][RatioTOP] = dini_Float(Archivo, "Ratio");
- EnTop[TopP[Lugar]] = true;
- MAX_VALOR = -1;
- Lugar++;
- }
- //RESETEAR DATOS:
- for(new s = 0; s < MAX_DATOS; s++)
- {
- EnTop[s] = false;
- NOMBRE[s][0] = 0;
- VALOR[s] = 0.0;
- }
- //GUARDAR DATOS EN UNA CADENA DE CARACTERES
- format(DLG_TOP_PLY_STR, sizeof(DLG_TOP_PLY_STR),"");
- Lugar = 1;
- while(Lugar < MAX_TOP_PLAYERS+1)
- {
- format(DLG_TOP_PLY_STR, sizeof(DLG_TOP_PLY_STR),
- "%s| %02d | %s | Asesinatos: %d | Muertes: %d | Ratio: %0.0f|\n",
- DLG_TOP_PLY_STR, Lugar, TopInfoP[Lugar][NickTOP], TopInfoP[Lugar][AsesinatosTOP],
- TopInfoP[Lugar][MuertesTOP], TopInfoP[Lugar][RatioTOP]);
- Lugar++;
- }
- SetTimer("ActualizarTopPlayers", 60000, 0);
- SetTimer("ActualizarListaJugadores", 10000, 0);
- }
- stock Registrar(playerid, pass[])
- {
- new
- Archivo[64],
- str[128];
- format(Archivo, sizeof(Archivo), "Jugadores/%s.ini", NickName(playerid));
- if(!dini_Exists(Archivo))
- {
- dini_Create(Archivo);
- dini_Set(Archivo, "Contrasena", pass);
- dini_IntSet(Archivo, "Asesinatos", 0);
- dini_IntSet(Archivo, "Muertes", 0);
- dini_FloatSet(Archivo, "Ratio", 0.0);
- dini_Set(Archivo, "Clan", "<Ninguno>");
- format(str, sizeof(str), "Nick '%s' registrado. Contrasena: '%s' ", NickName(playerid), pass);
- SendClientMessage(playerid, NICESKY, str);
- Registrado[playerid] = true;
- SendClientMessage(playerid, NARANJA, "Ahora usa /login [contraseña]");
- }
- }
- stock Login(playerid, pass[])
- {
- new
- Archivo[64],
- Nick[MAX_PLAYER_NAME];
- format(Archivo, sizeof(Archivo), "Jugadores/%s.ini", NickName(playerid));
- if(dini_Exists(Archivo))
- {
- if(!strcmp(dini_Get(Archivo, "Contrasena"), pass, false))
- {
- strmid(Nickname[playerid], NickName(playerid), 0, MAX_PLAYER_NAME, MAX_PLAYER_NAME);
- Asesinatos[playerid] = dini_Int(Archivo, "Asesinatos");
- Muertes[playerid] = dini_Int(Archivo, "Muertes");
- Ratio[playerid] = dini_Float(Archivo, "Ratio");
- Ingresado[playerid] = true;
- format(Archivo, sizeof Archivo, "Clanes/%s.ini", dini_Get(Archivo, "Clan"));
- if(dini_Exists(Archivo))
- {
- format(Clan_TAG[playerid], 4, dini_Get(Archivo, "TAG"));
- format(Nick, sizeof Nick, "[%s]%s", Clan_TAG[playerid], Nickname[playerid]);
- SetPlayerName(playerid, Nick);
- SetPlayerColor(playerid, dini_Int(Archivo, "Color"));
- Clan_ID[playerid] = dini_Int(Archivo, "ID");
- EnClan[playerid] = true;
- }
- SendClientMessage(playerid, NICESKY, "Logueado Correctamente");
- } else SendClientMessage(playerid, ROJO, "Contraseña Incorrecta");
- }
- }
- stock NickName(playerid)
- {
- new
- NickP[MAX_PLAYER_NAME];
- GetPlayerName(playerid, NickP, MAX_PLAYER_NAME);
- return NickP;
- }
- //Por Zamaroht
- stock RGBA(red, green, blue, alpha)
- {
- return (red * 16777216) + (green * 65536) + (blue * 256) + alpha;
- }
- //Por Zoutdaxv
- stock IsAHexNumber(string[])
- {
- new
- longitud = strlen(string);
- if(longitud == 0) return false;
- for(new s = 0; s < longitud; s++)
- {
- if(string[s] < 48 || string[s] > 57 && string[s] < 65 || string[s] > 70)
- {
- return false;
- }
- }
- return true;
- }
- //Por Dracoblue
- stock HexToInt(string[])
- {
- if(string[0] == 0) return 0;
- new
- i = strlen(string),
- cur = 1,
- res = 0;
- for( ; i > 0; i--)
- {
- if(string[i-1] < 58) res = res + cur * (string[i-1] - 48);
- else res = res + cur * (string[i-1] - 55);
- cur = cur * 16;
- }
- return res;
- }
- //Por Zoutdaxv
- stock DeleteLine(filename[], Line)
- {
- new
- string[128],
- temp[64],
- File:file,
- File:filetemp,
- l = 0;
- if(!fexist(filename)) return 0;
- format(temp, sizeof(temp), "%s.zzz", filename);
- filetemp = fopen(temp, io_write);
- file = fopen(filename, io_read);
- while(fread(file, string))
- {
- l++;
- if(l == Line) continue;
- fwrite(filetemp, string);
- }
- fclose(file);
- fclose(filetemp);
- file = fopen(filename, io_write);
- filetemp = fopen(temp, io_read);
- while(fread(filetemp, string))
- {
- fwrite(file, string);
- }
- fclose(file);
- fclose(filetemp);
- fremove(temp);
- return 1;
- }
- stock strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
- stock strrest(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[24];
- while ((index < length) && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement