Buenas vengo a aportar este plugin que contiene: Rangos + habilidades + Chat admin + Prefijo admin +Configuracion del hud
Este plugin a diferencia del de @kikizon2 este tiene guardado sqlite (tiene que estar habilitado en cstrike/addons/amxmodx/configs/module.ini) y tiene autenticacion por hwid.
Tienen que tener instalada la API DE DESTRO <----- y les andará muy bien!
Espero que les agrade, saludos a todos.
Cualquier bug o duda comentelas y lo editare o ayudare
DHUDMESSAGE.INC
Este plugin a diferencia del de @kikizon2 este tiene guardado sqlite (tiene que estar habilitado en cstrike/addons/amxmodx/configs/module.ini) y tiene autenticacion por hwid.
Tienen que tener instalada la API DE DESTRO <----- y les andará muy bien!
Espero que les agrade, saludos a todos.
Cualquier bug o duda comentelas y lo editare o ayudare
Código PHP:
#include <amxmodx>
#include <amxmisc>
#include <sqlx>
#include <colorchat>
#include <engine>
#include <api_sxei>
#include <dhudmessage>
#include <cstrike>
new const gPlugin[][] =
{
"Rangos System", // NOMBRE
"2.0", // VERSION
"Deev", // AUTOR
"/amxmodx-es.com/", // PREFIJO
"GGIZI", // TABLA
"RangoSystem" // BASE DE DATOS
};
new gHid[33][64], gNombre[33][32], gFrags[33], gRango[33], gMuertes[33];
new Handle:gTuple;
new gMaxplayers, gHud;
new gCam[33];
new InfoHMENU[33], MENUTOP[33][15][64];
new TOPID, TOPMAX;
new KEYSMENU = MENU_KEY_0 | MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 |
MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_9;
new Flags;
new g_AdminTag[33][10];
enum _:Data2 {
TAG[10],
FLAG
};
new const AdminsTags[][Data2] = {
{ "DUEÑO", ADMIN_RCON },
{ "STAFF", ADMIN_IMMUNITY },
{ "ADMIN", ADMIN_KICK }
};
enum
{
gCargarDatos,
gGuardarDatos,
gInsertarDatos
};
enum _:RANGOS
{
RANGOS_NAME[120],
RANGOS_FRAGS
};
new gRangos[][_:RANGOS] =
{
{ "Novato", 100 },
{ "Silver I", 200 },
{ "Silver II", 300 },
{ "Silver III", 500 },
{ "Silver IV", 700 },
{ "Silver Elite", 800 },
{ "Silver Elite Master", 900 },
{ "Gold Nova I", 1000 },
{ "Gold Nova II", 1200 },
{ "Gold Nova III", 1300 },
{ "Gold Nova Master", 1400 },
{ "Master Guardian I", 1500 },
{ "Master Guardian II", 1700 },
{ "Master Guardian Elite", 1800 },
{ "Distinguished Master Guardian", 1900 },
{ "Legendary Eagle", 2000 },
{ "Legendary Eagle Master", 2100 },
{ "Supreme Master First Class", 2200 },
{ "The Global Elite", 2500 }
};
enum _:DataColor1
{
Color_Nombre1[33],
C_R1,
C_G1,
C_B1
};
new const gColores1[][_:DataColor1] =
{
/* /NOMBRE/ /R/ /G/ /B/ */
{ "Original", 0, 255, 0 },
{ "Blanco", 255, 255, 255 },
{ "Verde", 0, 255, 0 },
{ "Azul", 0, 0, 255 },
{ "Rojo", 255, 0, 0 },
{ "Amarillo", 255, 255, 0 },
{ "Rosado", 255, 0, 255 },
{ "Naranja", 255, 128, 0 },
{ "Gris", 64, 64, 64 }
};
enum _:DataColor2
{
Color_Nombre2[33],
C_R2,
C_G2,
C_B2
};
new const gColores2[][_:DataColor2] =
{
/* /NOMBRE/ /R/ /G/ /B/ */
{ "Original", 255, 0, 0 },
{ "Blanco", 255, 255, 255 },
{ "Verde", 0, 255, 0 },
{ "Azul", 0, 0, 255 },
{ "Rojo", 255, 0, 0 },
{ "Amarillo", 255, 255, 0 },
{ "Rosado", 255, 0, 255 },
{ "Naranja", 255, 128, 0 },
{ "Gris", 64, 64, 64 }
};
enum _:DataColor3
{
Color_Nombre3[33],
C_R3,
C_G3,
C_B3
};
new const gColores3[][_:DataColor3] =
{
/* /NOMBRE/ /R/ /G/ /B/ */
{ "Original", 0, 191, 255 },
{ "Blanco", 255, 255, 255 },
{ "Verde", 0, 255, 0 },
{ "Azul", 0, 0, 255 },
{ "Rojo", 255, 0, 0 },
{ "Amarillo", 255, 255, 0 },
{ "Rosado", 255, 0, 255 },
{ "Naranja", 255, 128, 0 },
{ "Gris", 64, 64, 64 }
};
new gColor1[33], gColor2[33], gColor3[33];
public plugin_precache()
{
precache_model("models/rpgrocket.mdl");
}
public plugin_init()
{
register_plugin(gPlugin[0], gPlugin[1], gPlugin[2]);
register_clcmd("say", "SayHook");
register_clcmd("say_team", "message_sayteam")
register_clcmd("chooseteam", "changeteam");
register_clcmd("jointeam", "changeteam");
register_menu("Contacto", KEYSMENU, "handler_contacto");
register_menu("menu top", KEYSMENU, "top");
register_menu("HMENUINFOTOP", KEYSMENU, "HMENUINFOTOP");
register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
register_event("DeathMsg", "EventoM", "a");
gMaxplayers = get_maxplayers();
gHud = CreateHudSyncObj();
Inicio_sql();
}
/* TOP 15 */
public clcmd_top(id, page)
{
static szQuery[256], iData[2]
formatex(szQuery, 255, "SELECT * FROM `%s` ORDER BY `Frags` DESC LIMIT 15", gPlugin[4])
TOPID = page;
iData[0] = id;
iData[1] = TOPID;
SQL_ThreadQuery(gTuple, "menu_top", szQuery, iData, 2);
return PLUGIN_CONTINUE;
}
public menu_top(iFailState, Handle:Query, szError[], iError, iData[], iDataSize, Float:fQueueTime)
{
if(iFailState == TQUERY_CONNECT_FAILED || iFailState == TQUERY_QUERY_FAILED)
{
log_amx("%s", szError)
return
}
else
{
new id = iData[0];
if(SQL_NumResults(Query))
{
new menu[1750], len, count, cuenta[33], t[200];
len = count = 0;
len += formatex(menu[len], sizeof menu - 1 - len, "\d/amxmodx-es.com/\w Top 15\d (%d/3)^n^n", iData[1])
TOPMAX = SQL_NumResults(Query);
while(SQL_MoreResults(Query))
{
count++;
SQL_ReadResult(Query, 2, cuenta, 32)
formatex(t, charsmax(t), "\y%d. \y#%d\w %s\d |\y (\dRango: %s\y)^n", count - (iData[1] == 2 ? 5 : iData[1] == 3 ? 10 : 0), count, cuenta, gRangos[SQL_ReadResult(Query, 3)][RANGOS_NAME]);
if(count <= 5 && iData[1] == 1)
{
len += formatex(menu[len], sizeof menu - 1 - len, "%s", t);
}
else if(iData[1] == 1)
{
break;
}
if(count > 5 && count <= 10 && iData[1] == 2)
len += formatex(menu[len], sizeof menu - 1 - len, "%s", t);
else if(iData[1] == 2 && count > 5)
{
break;
}
if(count > 10 && count <= 15 && iData[1] == 3)
len += formatex(menu[len], sizeof menu - 1 - len, "%s", t);
else if(iData[1] == 3 && count > 10)
{
break;
}
SQL_ReadResult(Query, 0, MENUTOP[id][count-1], charsmax(MENUTOP[][]));
InfoHMENU[id] = count;
SQL_NextRow(Query);
}
if(iData[1] != 1) len += formatex(menu[len], sizeof menu - 1 - len, "^n\y8.\w Anterior^n")
else len += formatex(menu[len], charsmax(menu) - len, "^n");
if(iData[1] != 3) len += formatex(menu[len], sizeof menu - 1 - len, "\y9.\w Siguiente^n")
else len += formatex(menu[len], charsmax(menu) - len, "^n");
len += formatex(menu[len], sizeof menu - 1 - len, "\y0.\w Salir")
show_menu(id, KEYSMENU, menu, -1, "menu top")
}
}
return;
}
public top(id, key)
{
switch(key)
{
case 7:
{
if(TOPID == 3)
TOPID = 2;
else if (TOPID == 2)
TOPID = 1;
else TOPID = 1;
clcmd_top(id, TOPID)
}
case 8:
{
if(TOPID == 1)
TOPID = 2;
else if (TOPID == 2)
TOPID = 3;
else TOPID = 1;
clcmd_top(id, TOPID)
}
case 9:
return PLUGIN_HANDLED;
default:
{
static szQuery[256], iData[1];
iData[0] = id;
switch(TOPID){
case 2: key += 5;
case 3: key += 5;
}
InfoHMENU[id] = key;
formatex(szQuery, 255, "SELECT * FROM %s WHERE HWID=^"%s^"", gPlugin[4], MENUTOP[id][key]);
SQL_ThreadQuery(gTuple, "MENUINFOTOP", szQuery, iData, 1);
}
}
client_cmd(id, "spk buttons/button9.wav");
return PLUGIN_HANDLED
}
public MENUINFOTOP(iFailState, Handle:Query, szError[], iError, iData[], iDataSize, Float:fQueueTime) {
if(iFailState == TQUERY_CONNECT_FAILED || iFailState == TQUERY_QUERY_FAILED) {
log_to_file("TOP.ini", szError)
return PLUGIN_HANDLED;
}
else{
new id = iData[0];
if(SQL_NumResults(Query)){
static Nombre[32], datos[3], menu[1750], len;len = 0;
SQL_ReadResult(Query, 2, Nombre, charsmax(Nombre));
len += formatex(menu[len], sizeof menu - 1 - len, "\d/amxmodx-es.com/\w Estadisticas de\y %s (\d#%d\y)^n^n", Nombre, InfoHMENU[id]+1);
datos[0] = SQL_ReadResult(Query, 3);
datos[1] = SQL_ReadResult(Query, 1);
datos[2] = SQL_ReadResult(Query, 4);
len += formatex(menu[len], sizeof menu - 1 - len, "\
\wLugar del TOP:\y (\d#%d\y)^n\
\wNombre:\y (\d%s\y)^n\
\wRango:\y (\d%s\y)^n\
\wFrags:\y (\d%d\y)^n\
\wMuertes:\y (\d%d\y)^n^n",\
InfoHMENU[id]+1, Nombre, gRangos[datos[0]][RANGOS_NAME], datos[1], datos[2]);
len += formatex(menu[len], sizeof menu - 1 - len, "\y0.\w Volver");
show_menu(id, KEYSMENU, menu, -1, "HMENUINFOTOP");
}
}
return PLUGIN_HANDLED;
}
public HMENUINFOTOP(id, key)
{
switch(key)
{
case 9: clcmd_top(id, 1);
}
client_cmd(id, "spk buttons/button9.wav");
return PLUGIN_HANDLED;
}
/* ======= */
public changeteam(id)
{
if(cs_get_user_team(id) == CS_TEAM_UNASSIGNED || cs_get_user_team(id) == CS_TEAM_SPECTATOR)
return PLUGIN_CONTINUE;
show_menu_principal(id);
return PLUGIN_HANDLED;
}
public fw_recv_hid(id, const hid[])
{
if(is_user_connected(id) && strlen(hid) > 12)
{
format(gHid[id], charsmax(gHid[]), hid);
static szQuery[900], iData[2], ip[24], authid[64];
get_user_ip(id, ip, charsmax(ip), true);
get_user_authid(id, authid, charsmax(authid));
iData[0] = id;
iData[1] = gCargarDatos;
formatex(szQuery, charsmax(szQuery), "SELECT * FROM '%s' WHERE HWID=^"%s^"", gPlugin[4], hid);
SQL_ThreadQuery(gTuple, "SQL_Handler", szQuery, iData, 2);
log_to_file("Logs_Jugadores.txt", "NOMBRE: %s | HID: %s | IP: %s | AUTHID: %s", gNombre[id], hid, ip, authid);
}
}
public show_menu_principal(id)
{
static gTexto[1204], gMenu;
formatex(gTexto, charsmax(gTexto), "\y==============================^n\wBienvenido %s\n\wMenu Principal^n\y==============================", gNombre[id]);
gMenu = menu_create(gTexto, "handler_principal");
menu_additem(gMenu, "Cambiarme de equipo");
menu_additem(gMenu, "Contacto / Precios");
menu_additem(gMenu, "Servidores");
menu_additem(gMenu, "Configuración");
menu_setprop(gMenu, MPROP_BACKNAME, "Atrás");
menu_setprop(gMenu, MPROP_NEXTNAME, "Siguiente");
menu_setprop(gMenu, MPROP_EXITNAME, "Salir");
menu_setprop(gMenu, MPROP_NUMBER_COLOR, "\y");
menu_display(id, gMenu, 0);
return PLUGIN_HANDLED;
}
public handler_principal(id, menu, item)
{
switch(item)
{
case MENU_EXIT:
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
case 0:
show_menu_cambiarme(id);
case 1:
show_menu_contacto(id);
case 2:
client_cmd(id, "say /server");
case 3:
show_menu_configuracion(id);
}
client_cmd(id, "spk buttons/button9.wav");
menu_destroy(menu);
return PLUGIN_HANDLED;
}
public show_menu_cambiarme(id)
{
static gMenu, gTexto[1204];
gMenu = menu_create("\y==============================^n\wSelecciona un equipo^n\y==============================", "handler_cambiarme");
formatex(gTexto, charsmax(gTexto), "\%sMilico", cs_get_user_team(id) == CS_TEAM_CT ? "d" : "w");
menu_additem(gMenu, gTexto);
formatex(gTexto, charsmax(gTexto), "\%sLadron", cs_get_user_team(id) == CS_TEAM_T ? "d" : "w");
menu_additem(gMenu, gTexto);
formatex(gTexto, charsmax(gTexto), "\%sEspectador", cs_get_user_team(id) == CS_TEAM_SPECTATOR ? "d" : "w");
menu_additem(gMenu, gTexto);
menu_setprop(gMenu, MPROP_EXITNAME, "Salir");
menu_setprop(gMenu, MPROP_NUMBER_COLOR, "\y");
menu_display(id, gMenu, 0);
return PLUGIN_HANDLED;
}
public handler_cambiarme(id, menu, item)
{
switch(item)
{
case MENU_EXIT:
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
case 0:
{
if(cs_get_user_team(id) == CS_TEAM_CT)
{
ColorChat(id, GREEN, "%s^1 Ya estas en el equipo^4 Milico^1.", gPlugin[3]);
return PLUGIN_HANDLED;
}
else {
cs_set_user_team(id, CS_TEAM_CT);
player_kill(id);
}
}
case 1:
{
if(cs_get_user_team(id) == CS_TEAM_T)
{
ColorChat(id, GREEN, "%s^1 Ya estas en el equipo^4 Ladron^1.", gPlugin[3]);
return PLUGIN_HANDLED;
}
else {
cs_set_user_team(id, CS_TEAM_T);
player_kill(id);
}
}
case 2:
{
if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
{
ColorChat(id, GREEN, "%s^1 Ya estas en el equipo^4 Espectador^1.", gPlugin[3]);
return PLUGIN_HANDLED;
}
else {
cs_set_user_team(id, CS_TEAM_SPECTATOR);
player_kill(id);
}
}
}
client_cmd(id, "spk buttons/button9.wav");
menu_destroy(menu);
return PLUGIN_HANDLED;
}
public show_menu_contacto(id)
{
static gTexto[1204], gLen;
gLen = 0;
gLen += formatex(gTexto[gLen], sizeof gTexto - 1 - gLen, "\y==============================^n\wContacto/Precios^n\y==============================^n^n");
gLen += formatex(gTexto[gLen], sizeof gTexto - 1 - gLen, "\y* \wAdmin FULL:\d $^n");
gLen += formatex(gTexto[gLen], sizeof gTexto - 1 - gLen, "\y* \wAdmin COMUN:\d $^n");
gLen += formatex(gTexto[gLen], sizeof gTexto - 1 - gLen, "\y* \wFanpage:^n");
gLen += formatex(gTexto[gLen], sizeof gTexto - 1 - gLen, "\y* \wForo:");
gLen += formatex(gTexto[gLen], sizeof gTexto - 1 - gLen, "\y* \wGrupo:^n");
gLen += formatex(gTexto[gLen], sizeof gTexto - 1 - gLen, "\d\y* \Web^n");
gLen += formatex(gTexto[gLen], sizeof gTexto - 1 - gLen, "\y0. \wSalir");
show_menu(id, KEYSMENU, gTexto, -1, "Contacto");
return PLUGIN_HANDLED;
}
public handler_contacto(id, key)
{
switch(key)
{
case 9:
{
client_cmd(id, "spk buttons/button9.wav");
return PLUGIN_HANDLED;
}
}
client_cmd(id, "spk buttons/button9.wav");
return PLUGIN_HANDLED;
}
public EventoM()
{
static gAttacker, gVictim;
gAttacker = read_data(1);
gVictim = read_data(2);
if(gAttacker == gVictim || !is_user_connected(gAttacker) || !is_user_connected(gVictim))
return;
gFrags[gAttacker] ++;
gMuertes[gVictim] ++;
chequear_rango(gAttacker);
}
public show_menu_configuracion(id)
{
static gTexto[1204], gMenu;
gMenu = menu_create("\y==============================n\wConfiguración^n\y==============================", "handler_configuracion");
formatex(gTexto, charsmax(gTexto), "Color HUD FRAGS \d[%s]", gColores1[gColor1[id]][Color_Nombre1]);
menu_additem(gMenu, gTexto);
formatex(gTexto, charsmax(gTexto), "Color HUD RANGO \d[%s]", gColores2[gColor2[id]][Color_Nombre2]);
menu_additem(gMenu, gTexto);
formatex(gTexto, charsmax(gTexto), "Color HUD SIGUIENTE \d[%s]^n", gColores3[gColor3[id]][Color_Nombre3]);
menu_additem(gMenu, gTexto);
formatex(gTexto, charsmax(gTexto), "Camara \d[%s]", gCam[id] == 1 ? "3ra persona" : "1ra persona");
menu_additem(gMenu, gTexto);
menu_setprop(gMenu, MPROP_EXITNAME, "Salir");
menu_setprop(gMenu, MPROP_NUMBER_COLOR, "\y");
menu_display(id, gMenu, 0);
return PLUGIN_HANDLED;
}
public handler_configuracion(id, menu, item)
{
switch(item)
{
case MENU_EXIT:
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
case 0:
show_menu_color1(id);
case 1:
show_menu_color2(id);
case 2:
show_menu_color3(id);
case 3:
{
if(gCam[id] == 1)
{
set_view(id, CAMERA_NONE);
gCam[id] = 0;
}
else
{
set_view(id, CAMERA_3RDPERSON);
gCam[id] = 1;
}
show_menu_configuracion(id);
}
}
client_cmd(id, "spk buttons/button9.wav");
menu_destroy(menu);
return PLUGIN_HANDLED;
}
public show_menu_color1(id)
{
static gMenu, gTexto[1204];
formatex(gTexto, charsmax(gTexto), "\y==============================^n\d[HIGH COMUNIDAD]^n\wColor Hud^n\wActual: \y[\d%s\y]^n\y==============================", gColores1[gColor1[id]][Color_Nombre1]);
gMenu = menu_create(gTexto, "handler_color1");
for(new i; i < sizeof gColores1; i++)
menu_additem(gMenu, gColores1[i][Color_Nombre1]);
menu_setprop(gMenu, MPROP_BACKNAME, "Atrás");
menu_setprop(gMenu, MPROP_EXITNAME, "Volver");
menu_setprop(gMenu, MPROP_NEXTNAME, "Siguiente");
menu_setprop(gMenu, MPROP_NUMBER_COLOR, "\y");
menu_display(id, gMenu, 0);
return PLUGIN_HANDLED;
}
public handler_color1(id, menu, key)
{
if(key == MENU_EXIT)
{
show_menu_configuracion(id);
return;
}
gColor1[id] = key;
menu_display(id, menu);
client_cmd(id, "spk buttons/button9.wav");
}
public show_menu_color2(id)
{
static gMenu, gTexto[1204];
formatex(gTexto, charsmax(gTexto), "\y==============================^n\wColor Hud^n\wActual: \y[\d%s\y]^n\y==============================", gColores2[gColor2[id]][Color_Nombre2]);
gMenu = menu_create(gTexto, "handler_color2");
for(new i; i < sizeof gColores2; i++)
menu_additem(gMenu, gColores2[i][Color_Nombre2]);
menu_setprop(gMenu, MPROP_BACKNAME, "Atrás");
menu_setprop(gMenu, MPROP_EXITNAME, "Volver");
menu_setprop(gMenu, MPROP_NEXTNAME, "Siguiente");
menu_setprop(gMenu, MPROP_NUMBER_COLOR, "\y");
menu_display(id, gMenu, 0);
return PLUGIN_HANDLED;
}
public handler_color2(id, menu, key)
{
if(key == MENU_EXIT)
{
show_menu_configuracion(id);
return;
}
gColor2[id] = key;
menu_display(id, menu);
client_cmd(id, "spk buttons/button9.wav");
}
public show_menu_color3(id)
{
static gMenu, gTexto[1204];
formatex(gTexto, charsmax(gTexto), "\y==============================^n\wColor Hud^n\wActual: \y[\d%s\y]^n\y==============================", gColores3[gColor3[id]][Color_Nombre3]);
gMenu = menu_create(gTexto, "handler_color3");
for(new i; i < sizeof gColores3; i++)
menu_additem(gMenu, gColores3[i][Color_Nombre3]);
menu_setprop(gMenu, MPROP_BACKNAME, "Atrás");
menu_setprop(gMenu, MPROP_EXITNAME, "Volver");
menu_setprop(gMenu, MPROP_NEXTNAME, "Siguiente");
menu_setprop(gMenu, MPROP_NUMBER_COLOR, "\y");
menu_display(id, gMenu, 0);
return PLUGIN_HANDLED;
}
public handler_color3(id, menu, key)
{
if(key == MENU_EXIT)
{
show_menu_configuracion(id);
return;
}
gColor3[id] = key;
menu_display(id, menu);
client_cmd(id, "spk buttons/button9.wav");
}
public chequear_rango(id)
{
static gSubio;
gSubio = false;
get_user_name(id, gNombre[id], charsmax(gNombre[]));
if(gFrags[id] >= gRangos[gRango[id]][RANGOS_FRAGS])
{
gRango[id]++;
gSubio = true;
}
if(gSubio)
{
ColorChat(0, GREEN, "%s^1 El jugador^4 %s^1 subió al rango^4 %s^1.", gPlugin[3], gNombre[id], gRangos[gRango[id]][RANGOS_NAME]);
client_cmd(0, "spk events/task_complete.wav");
gSubio = false;
}
set_task(0.1, "chequear_rango", id);
return PLUGIN_HANDLED;
}
public SayHook(id)
{
static say[192], Mensaje[250];
say[0] = Mensaje[0] = '^0';
read_args(say, charsmax(say));
remove_quotes(say);
trim(say);
get_user_name(id, gNombre[id], charsmax(gNombre[]));
if(!ValidMessage(say))
return PLUGIN_HANDLED;
if(containi(say, "/top") != -1)
clcmd_top(id, 1);
if(containi(say, "/top15") != -1)
clcmd_top(id, 1);
if(is_user_admin(id))
formatex(Mensaje, charsmax(Mensaje), "^x01%s (^x04%s^x01)^x04 %s^x01-> ^x03 %s ^x01: ^x04%s", is_user_alive(id) ? "" : "*MUERTO* ", gRangos[gRango[id]][RANGOS_NAME], g_AdminTag[id], gNombre[id], say);
else
formatex(Mensaje, charsmax(Mensaje), "^x01%s [^x04%s^x01] (^x04%s^x01)^x03 %s ^x01: %s", is_user_alive(id) ? "" : "*MUERTO* ", gRangos[gRango[id]][RANGOS_NAME], gNombre[id], say);
switch(get_user_team(id))
{
case 0: ColorChat(0, GREY, "^1*SPEC*^3 %s^01 : %s", gNombre[id], say)
case 3: ColorChat(0, GREY, "^1*SPEC*^3 %s^1 : %s", gNombre[id], say)
case 2: ColorChat(0, BLUE, Mensaje)
case 1: ColorChat(0, RED, Mensaje)
}
log_to_file("Log_Say.txt", "%s: %s", gNombre[id], say)
return PLUGIN_HANDLED;
}
public message_sayteam(id)
{
static say[192], Mensaje[250];
say[0] = Mensaje[0] = '^0';
read_args(say, charsmax(say));
remove_quotes(say);
trim(say);
if(!ValidMessage(say))
return PLUGIN_HANDLED;
static playerTeam, playerTeamName[19];
playerTeam = get_user_team(id);
switch (playerTeam) {
case 1: copy (playerTeamName, 6, "Chorro");
case 2: copy (playerTeamName, 8, "Policia");
default: copy (playerTeamName, 11, "**SPEC**");
}
static color[11], name[32], alive[11];
get_user_team(id,color,charsmax(color));
get_user_name(id,name,charsmax(name));
if (is_user_alive (id)) {
alive = "";
} else {
alive = "(MUERTO)";
}
if (is_user_admin(id)) {
if (get_user_flags(id))
format(say, charsmax(say), "^x01%s [^x04%s^x01] (^x04%s^x01)^x04 %s^x01-> ^x03 %s ^x01: %s", alive, playerTeam, gRangos[gRango[id]][RANGOS_NAME], g_AdminTag[id], name, say);
} else {
format(say, charsmax(say), "^x01%s [^x04%s^x01] (^x04%s^x01)^x03 %s ^x01: %s", alive, playerTeam, gRangos[gRango[id]][RANGOS_NAME],name, say);
}
}
ValidMessage(text[])
{
static len, i
len = strlen(text)
if(!len)
return false;
for(i = 0; i < len; i++)
{
if( text[i] != ' ' )
{
return true;
}
}
return false;
}
public event_round_start()
{
for(new i = 1; i <= gMaxplayers; i++)
{
if(is_user_connected(i))
guardar_datos(i);
}
}
public client_putinserver(id)
{
get_user_name(id, gNombre[id], charsmax(gNombre[]));
set_task(1.0, "Mostrar_HUD", id+517, _, _, "b");
}
public Mostrar_HUD(id)
{
id -= 517;
static iSpec
iSpec = 0;
if(!is_user_alive(id))
{
iSpec = entity_get_int(id, EV_INT_iuser2);
if(!is_user_alive(iSpec))
return;
}
if(iSpec && id != iSpec)
{
set_hudmessage(64, 64, 64, 0.04, 0.16, 1, 6.0, 1.1, 0.0, 0.0, -1);
ShowSyncHudMsg(id, gHud, "Siguiendo a %s^n ^t^t^tFrags: %d - Rango: %s", gNombre[iSpec], gFrags[iSpec], gRangos[gRango[iSpec]][RANGOS_NAME]);
}
else
{
set_dhudmessage(gColores1[gColor1[id]][C_R1], gColores1[gColor1[id]][C_G1], gColores1[gColor1[id]][C_B1], 0.01, 0.16, 0, 6.0, 1.1, 0.0, 0.0, false)
show_dhudmessage(id, "[Frags: %d - %d]", gFrags[id], gRangos[gRango[id]][RANGOS_FRAGS] - gFrags[id])
set_dhudmessage(gColores2[gColor2[id]][C_R2], gColores2[gColor2[id]][C_G2], gColores2[gColor2[id]][C_B2], 0.01, 0.19, 0, 6.0, 1.1, 0.0, 0.0, false)
show_dhudmessage(id, "[Rango: %s]", gRangos[gRango[id]][RANGOS_NAME])
set_dhudmessage(gColores3[gColor3[id]][C_R3], gColores3[gColor3[id]][C_G3], gColores3[gColor3[id]][C_B3], 0.01, 0.22, 0, 6.0, 1.1, 0.0, 0.0, false)
show_dhudmessage(id, "[Siguiente: %s]", gRangos[gRango[id]+1][RANGOS_NAME])
}
}
public client_disconnect(id)
{
guardar_datos(id);
remove_task(id+517);
gHid[id][0] = '^0';
}
public guardar_datos(id)
{
static gData[2], gQuery[300];
gData[0] = id;
gData[1] = gGuardarDatos;
formatex(gQuery, charsmax(gQuery), "UPDATE '%s' SET Frags='%d', Nombre='%s', Rango='%d', Muertes='%d', HUD1='%d', HUD2='%d', HUD3='%d' WHERE HWID=^"%s^"", gPlugin[4], gFrags[id], gNombre[id], gRango[id], gMuertes[id], gColor1[id], gColor2[id], gColor3[id], gHid[id]);
SQL_ThreadQuery(gTuple, "SQL_Handler", gQuery, gData,2);
}
public SQL_Handler(failstate, Handle:Query,Error[], szError, Data[],szData[], Float:time)
{
static id;
id = Data[0];
if(!is_user_connected(id))
return;
if(failstate == TQUERY_CONNECT_FAILED || failstate == TQUERY_QUERY_FAILED)
log_to_file("SQLERROR.ini", "Error %d : %s", szError, Error);
switch(Data[1])
{
case gCargarDatos:
{
if(SQL_NumResults(Query))
{
gFrags[id] = SQL_ReadResult(Query, 1);
SQL_ReadResult(Query, 2, gNombre[id], charsmax(gNombre[]));
gRango[id] = SQL_ReadResult(Query, 3);
gMuertes[id] = SQL_ReadResult(Query, 4);
gColor1[id] = SQL_ReadResult(Query, 5);
gColor2[id] = SQL_ReadResult(Query, 6);
gColor3[id] = SQL_ReadResult(Query, 7);
}
else {
static gData[2], gQuery[300];
gData[0] = id;
gData[1] = gInsertarDatos;
formatex(gQuery, charsmax(gQuery), "INSERT INTO '%s' (HWID) VALUES (^"%s^")", gPlugin[4], gHid[id]);
SQL_ThreadQuery(gTuple, "SQL_Handler", gQuery, gData,2);
}
}
case gGuardarDatos:
{
if (failstate < TQUERY_SUCCESS)
ColorChat(id, GREEN, "%s^1 Error al guardar datos.", gPlugin[3]);
else {
if(cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED)
return;
ColorChat(id, GREEN, "%s^1 Datos guardados ^4(^1Frags: %d^4)^1 -^4 (^1Muertes: %d^4)^1.", gPlugin[3], gFrags[id], gMuertes[id]);
ColorChat(id, GREEN, "%s^1 ^4(^1Rango: %s^4)^1 -^4 (^1Nombre: %s^4)^1.", gPlugin[3], gRangos[gRango[id]][RANGOS_NAME], gNombre[id]);
}
}
case gInsertarDatos:
{
if(failstate < TQUERY_SUCCESS)
return;
else {
gFrags[id] = 1;
gMuertes[id] = gRango[id] = gColor1[id] = gColor2[id] = gColor3[id] = 0;
}
}
}
}
public Inicio_sql()
{
new get_type[12];
SQL_SetAffinity("sqlite")
SQL_GetAffinity(get_type,sizeof(get_type))
if(!equal(get_type,"sqlite"))
{
log_to_file("SqlEROR.txt", "Error al conectar con la base de datos");
return pause("a");
}
gTuple = SQL_MakeDbTuple("", "", "", gPlugin[4]);
return PLUGIN_HANDLED;
}
public plugin_end()
SQL_FreeHandle(gTuple);
stock player_kill(id)
{
new msgid = get_user_msgid("DeathMsg");
new msgblock = get_msg_block(msgid);
if(msgblock == BLOCK_NOT)
{
set_msg_block(msgid,BLOCK_ONCE);
user_kill(id, 1);
}
else if(msgblock == BLOCK_ONCE)
{
user_kill(id, 1);
set_msg_block(msgid, BLOCK_ONCE);
}
else
user_kill(id, 1);
return 1;
}
DHUDMESSAGE.INC
Aprendiendo 5%