06/01/2020, 09:50 AM
Buenas! Bueno paso por aquí para ver si alguien me ayuda con este plugin, el plugin usa el sistema "nfvault" pero no me guarda los rangos, por ejemplo una persona llegó a "Aventurero" pero cuando hace retry dice "Sin Rango" ayuda por fa, ya probé con adv_vault pero no me funciona el plugin en el servidor.
Código PHP:
#include <amxmisc>
#include <fakemeta>
#include <nfvault>
#include <cstrike>
#include <csx>
#include <fun>
#include <jctf>
#include <colorchat>
new const PLUGIN[] = "Nivel+Rangos"
#define VERSION "1.0"
new const AUTHOR[] = "kikizon"
/* =============================================
|= [EMPIEZA SECCION MODIFICABLE] =|
==============================================*/
/* ====================================
*[CONSTANTES]*
=====================================*/
new const WEB[] = "facebook.com/groups/Noobing.VE/"
#define SONIDO "misc/killChicken.wav"
/* ====================================
*[CONST NOMBRES DE RANGOS]*
=====================================*/
enum _:DATA { NOMBRE[30], FRAGS }
new const Rangos[][DATA] = {
{"Sin Rango", 1},
{"Recien llegado", 25},
{"Novato", 50},
{"Aventurero", 100},
{"Principiante", 150},
{"Experimentado", 200},
{"Civil I", 300},
{"Civil II", 600},
{"Recluta", 1200},
{"Alistado", 1600},
{"Soldado", 2000},
{"Distinguido", 2500},
{"Cabo I", 3500},
{"Cabo II", 4500},
{"Sargento I", 5000},
{"Sargento II", 5500},
{"Sargento Mayor I", 6000} ,
{"Sargento Mayor II", 6500},
{"Sargento Ayudante", 7000},
{"Sargento Supervisor", 7500},
{"Sargento Tecnico I", 8000},
{"Sargento Tecnico II", 8500},
{"Maestro Tecnico I", 9000},
{"Maestro Tecnico II", 9500},
{"Maestro Tecnico Mayor", 10000},
{"Maestro Tec. Supervisor", 11000},
{"Cadete", 12000},
{"Sub-Brigadier", 13000},
{"Brigadier", 14000},
{"Primer Brigadier", 15000},
{"Brigadier Mayor", 16000},
{"Alferez", 17000},
{"Teniente", 18000},
{"Primer Teniente", 19000},
{"Capitan", 20000},
{"Mayor", 22000},
{"Teniente Coronel", 24000},
{"Comandante", 26000},
{"Coronel", 28000},
{"General de Brigada", 30000},
{"General de Division", 33000},
{"Mayor General", 36000},
{"General en Jefe", 39000},
{"Guardia de Honor", 43000},
{"Fuerzas Especiales", 47000},
{"Asesino Profesional", 52000},
{"Selvatico Camuflado", 57000},
{"Desertico Experto", 63000},
{"Genocida", 69000},
{"Infanteria Profesional", 76000},
{"Artillero", 84000},
{"Artillero de Torreta", 92000},
{"Tanquista", 100000},
{"Tanquista Anfibio", 11000},
{"Bombardero Terrorista", 120000},
{"Blindado", 130000},
{"Blindado Explosivo", 140000},
{"Cazador I", 150000},
{"Cazador II", 160000},
{"Francotirador I", 170000},
{"Francotirador II", 180000},
{"Guardia de honor", 190000},
{"Fuerzas Especiales", 200000},
{"Destructor 1", 210000},
{"Destructor 2", 220000},
{"Masacrador 1", 230000},
{"Masacrador 2", 240000},
{"Exterminador 1", 250000},
{"Exterminador 2", 260000},
{"Nazi", 270000},
{"Destripador", 280000},
{"Berserker 1", 290000},
{"Berserker 2", 300000},
{"Grand Headshot", 320000},
{"Headshot Supremo", 340000},
{"Headshot Sagrado", 360000},
{"Headshot Dios", 380000},
{"Master Headshots 1", 400000},
{"Master Headshots 2", 420000},
{"Master Pro Kill 1", 440000},
{"Master Pro Kill 2", 460000},
{"Silver 1", 480000},
{"Silver 2", 500000},
{"Silver 3", 520000},
{"Silver 4", 540000},
{"Silver Elite", 560000},
{"Silver Elite Master", 580000},
{"Gold Nova 1", 600000},
{"Gold Nova 2", 620000},
{"Gold Nova 3", 640000},
{"Gold Nova Master", 660000},
{"Master Guardian 1", 680000},
{"Master Guardian 2", 700000},
{"Master Guardian Elite", 720000},
{"Disting. Master Guardian", 740000},
{"Legendary Eagle", 760000},
{"Legendary Eagle Master", 780000},
{"Supreme Master First Class", 800000},
{"The Global Elite", 820000},
{"Pro Gamers Finish 1", 840000},
{"Pro Gamers Finish 2", 900000},
{"NoobingGamer`s", 9999999}
};
/* =============================================
|= [TERMINA SECCION MODIFICABLE] =|
==============================================*/
/* ====================================
*[VARIABLES]*
=====================================*/
new g_rango[33], g_frags[33]
new SyncHUD, g_maxplayers, g_msgTeamInfo, g_msgSayText, g_playername[33][32];
#define TASK_HUD 2100
#define ID_HUD (taskid - TASK_HUD)
#define XD is_user_connected(id) || !is_user_bot(id) || !is_user_hltv(id)
new VaultRango[128], szRangos[180], szKey[30]
new g_iCreateHud, g_iMsgStatusText
/* ====================================
*[Cvars]*
=====================================*/
new cvar_Hud, cvar_knifex2, cvar_hsx2, cvar_awpx2, cvar_scoutx2, cvar_hex2
/* ====================================
*[INIT]*
=====================================*/
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
//register_event("DeathMsg", "Event_DeathMsg", "a")
register_clcmd( "say /rangos", "OnPlayerPrint_Ranks" );
register_clcmd( "say_team /rangos", "OnPlayerPrint_Ranks" );
register_clcmd("say", "message_saytext")
register_clcmd("say_team", "message_sayteam")
register_event("StatusValue", "HookShowStatus", "b", "1=2", "2>0")
register_event("StatusValue", "HookHideStatus", "b", "1=1", "2=0")
/* =============================================
|= [EMPIEZA SECCION MODIFICABLE] =|
==============================================*/
cvar_Hud = register_cvar("rangos_hud", "1") // 1 - Saldra El HUD | 0 - Lo Desactivas
cvar_knifex2 = register_cvar("rangos_knifex2", "1") // 1 - x2 frags con knife | 0 - Lo Desactivas
cvar_hsx2 = register_cvar("rangos_hsx2", "1") // 1 - x2 frags de HeadShot | 0 - Lo Desactivas
cvar_awpx2 = register_cvar("rangos_awpx2", "0") // 1 - x2 frags Con awp | 0 - Lo Desactivas
cvar_scoutx2 = register_cvar("rangos_scoutx2", "0") // 1 - x2 frags Con scout | 0 - Lo Desactivas
cvar_hex2 = register_cvar("rangos_hex2", "1") // 1 - x2 frags Con HE | 0 - Lo Desactivas // 1 - x2 frags de HeadShot | 0 - ÑO :v
/* =============================================
|= [TERMINA SECCION MODIFICABLE] =|
==============================================*/
SyncHUD = CreateHudSyncObj()
g_maxplayers = get_maxplayers()
g_msgTeamInfo = get_user_msgid("TeamInfo")
g_msgSayText = get_user_msgid("SayText")
g_iCreateHud = CreateHudSyncObj()
g_iMsgStatusText = get_user_msgid("StatusText")
nfv_file("Ranguitos", VaultRango, charsmax(VaultRango))
}
public plugin_cfg()
set_cvar_num("mp_playerid", 0);
/* ====================================
*[PRECACHE]*
=====================================*/
public plugin_precache()
precache_sound(SONIDO);
/* ===================================
*[HUD]*
=====================================*/
public OnPlayerPrint_Ranks( const iPlayerID ) {
if( !is_user_connected( iPlayerID ) )
return PLUGIN_CONTINUE;
for( new iNum = 0; iNum < sizeof( Rangos ); ++iNum )
console_print( iPlayerID, "[NoobingGamer`s] Rango #%i: [%s]", iNum, Rangos[ iNum ][ NOMBRE ] );
client_cmd( iPlayerID, "toggleconsole" );
return PLUGIN_HANDLED;
}
public HUD(taskid)
{
new id = ID_HUD
new izStats[8], izBody[8]
new iRankPos, iRankMax
iRankPos = get_user_stats(id, izStats, izBody)
iRankMax = get_statsnum()
if(!is_user_alive(id))
{
id = pev(id, pev_iuser2)
if(!is_user_alive(id))
return;
}
if(id != ID_HUD)
{
set_hudmessage(random_num(0, 255), random_num(0, 255), random_num(0, 255), 5.0, 4.0, -5.0, 0.5, 2.0)
ShowSyncHudMsg(ID_HUD, SyncHUD, "Frags: [%d] || Rango: [%s]", g_frags[id], Rangos[g_rango[id]][NOMBRE])
}
else
{
set_hudmessage(random_num(0, 255), random_num(0, 255), random_num(0, 255), 5.0, 10.0, -10.0, 1.0, 2.0)
ShowSyncHudMsg(ID_HUD, SyncHUD, "Frags:[%d/%d] || Rango:[%s]^nRanking: %d de %d | Adrenalina: %d / 100", g_frags[id], Rangos[g_rango[id]][FRAGS], Rangos[g_rango[id]][NOMBRE], iRankPos, iRankMax, jctf_get_adrenaline(id), WEB)
}
}
public HookShowStatus(id)
{
if(is_user_alive(id))
{
static pid
pid = read_data(2)
if(!is_user_alive(pid))
return
static team
team = get_user_team(pid)
message_begin(MSG_ONE_UNRELIABLE, g_iMsgStatusText, _, id)
write_byte(0)
write_string("")
message_end()
if(team == 1)
{
set_hudmessage(255, 0, 0, -1.0, 0.40, 2, 0.01, 3.0, 0.01, 0.01, -1)
ShowSyncHudMsg(id, g_iCreateHud, "[ %s ]^n%s", Rangos[g_rango[pid]][NOMBRE], g_playername[pid])
}
else if(team == 2)
{
set_hudmessage(0, 255, 255, -1.0, 0.40, 2, 0.01, 3.0, 0.01, 0.01, -1)
ShowSyncHudMsg(id, g_iCreateHud, "[ %s ]^n%s", Rangos[g_rango[pid]][NOMBRE], g_playername[pid])
}
}
}
public HookHideStatus(id)
ClearSyncHud(id, g_iCreateHud)
/* ==================================
[PUTINSERVER]
===================================*/
public client_putinserver(id)
{
get_user_name( id, g_playername[ id ], charsmax( g_playername[ ] ) );
g_rango[id] = 0
g_frags[id] = 0
Cargar(id)
if(get_pcvar_num(cvar_Hud))
set_task(1.5, "HUD", id+TASK_HUD, _, _, "b")
}
/* ==================================
[DISCONNECT]
===================================*/
public client_disconnected(id) {
if(XD) Guardar(id);
remove_task(id+TASK_HUD)
}
/* ==================================
[DEATHMSG]
===================================*/
/*public Event_DeathMsg() {
new attacker = read_data(1)
new victim = read_data(2)
new hs = read_data(3)
new weaponid = get_user_weapon(attacker)
if(victim == attacker) return;
if(is_user_alive(attacker)) {
g_frags[attacker] += ( is_user_admin( attacker ) ) ? 2:1;
Guardar(attacker)
if(get_pcvar_num(cvar_knifex2)) {
if(weaponid == CSW_KNIFE)
g_frags[attacker] += ( is_user_admin( attacker ) ) ? 2:1;
}
if(get_pcvar_num(cvar_hsx2)) {
if(hs) g_frags[attacker] += ( is_user_admin( attacker ) ) ? 2:1;
}
if(get_pcvar_num(cvar_awpx2)) {
if(weaponid == CSW_AWP)
g_frags[attacker] += ( is_user_admin( attacker ) ) ? 2: 1;
}
if(get_pcvar_num(cvar_scoutx2)) {
if(weaponid == CSW_SCOUT)
g_frags[attacker] += ( is_user_admin( attacker ) ) ? 2: 1;
}
if(get_pcvar_num(cvar_hex2)) {
if(weaponid == CSW_HEGRENADE)
g_frags[attacker] += ( is_user_admin( attacker ) ) ? 2: 1;
}
AumentarRango(attacker)
}
}*/
public client_death( attacker, victim, weapon, hitplace )
{
if(!is_user_connected(attacker) || victim == attacker) return
g_frags[attacker] += ( is_user_admin( attacker ) ) ? 2: 1;
if( weapon == CSW_KNIFE ) {
if(get_pcvar_num(cvar_knifex2))
g_frags[attacker] += ( is_user_admin( attacker ) ) ? 2: 1;
}
if( hitplace == HIT_HEAD ) {
if(get_pcvar_num(cvar_hsx2))
g_frags[attacker] += ( is_user_admin( attacker ) ) ? 2: 1;
}
if( weapon == CSW_AWP ) {
if(get_pcvar_num(cvar_awpx2))
g_frags[attacker] += ( is_user_admin( attacker ) ) ? 2: 1;
}
if( weapon == CSW_SCOUT ) {
(get_pcvar_num(cvar_scoutx2))
g_frags[attacker] += ( is_user_admin( attacker ) ) ? 2: 1;
}
if( weapon == CSW_HEGRENADE ) {
(get_pcvar_num(cvar_hex2))
g_frags[attacker] += ( is_user_admin( attacker ) ) ? 2: 1;
}
AumentarRango(attacker)
}
/* ================================
[UPDATE RANGO]
=================================*/
AumentarRango(id) {
new Aumento = false
while(g_frags[id] >= Rangos[g_rango[id]][FRAGS]) {
Aumento = true
g_rango[id]++
}
if(Aumento) {
new name[33]; get_user_name(id, name, 32)
ColorChat(id, GREY, "^1[^4NoobingGamer`s^1] !Felicidades! Tu Nuevo Rango es: [^4%s^1]", Rangos[g_rango[id]][NOMBRE])
ColorChat(0, GREY, "^1[^4NoobingGamer`s^1] !En Hora Buena! El Nuevo Rango de ^3%s ^1es: [^4%s^1]", name, Rangos[g_rango[id]][NOMBRE])
client_cmd ( id, "spk %s", SONIDO);
Aumento = false
}
}
/*=====================================
*[SAY]*
=====================================*/
public message_saytext(id)
{
static said[192]
read_args(said, charsmax(said))
remove_quotes(said)
if(said[0] == '%' || said[0] == '/' || said[0] == '@' || equal (said, "/"))
return PLUGIN_HANDLED
if(!ValidMessage(said, 1)) return PLUGIN_CONTINUE;
static color[11], name[32]
get_user_team(id,color,charsmax(color))
get_user_name(id,name,charsmax(name))
new alive = is_user_alive(id)
new is_adm = is_user_admin(id)
new tipo[32], flags = get_user_flags(id)
if (flags & ADMIN_LEVEL_B) formatex(tipo, charsmax(tipo), "DUEÑ@")
else if (flags & ADMIN_LEVEL_E) formatex(tipo, charsmax(tipo), "SOCIO")
else if (flags & ADMIN_LEVEL_C) formatex(tipo, charsmax(tipo), "VIP")
else if (flags & ADMIN_LEVEL_H) formatex(tipo, charsmax(tipo), "Baby GirL")
else if (flags & ADMIN_LEVEL_D) formatex(tipo, charsmax(tipo), "Spammer")
if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
{
if(is_adm)
format(said, charsmax(said), "^1*SPEC* ^3[^1%s^3] ^3NOOB. ^4%s ^1~> ^3%s :^4 %s", Rangos[g_rango[id]][NOMBRE], tipo, name, said)
else
format(said, charsmax(said), "^1*SPEC* ^3[^1%s^3]^1 %s : %s", Rangos[g_rango[id]][NOMBRE], name, said)
}
else
{
if(is_adm)
format(said, charsmax(said), "^1%s ^3[^1%s^3] ^3NOOB. ^4%s ^1~> ^3%s :^4 %s", alive ? "^1" : "^1*Muerto*", Rangos[g_rango[id]][NOMBRE], tipo, name, said)
else
format(said, charsmax(said), "^1%s ^3[^1%s^3]^1 ^3%s ^1: %s", alive ? "^1" : "^1*Muerto*", Rangos[g_rango[id]][NOMBRE], name, said)
}
static i, team[11]
for(i = 1; i <= g_maxplayers; i++)
{
if(!is_user_connected(i))
continue
get_user_name(id,name,charsmax(name))
get_user_team(i, team, charsmax(team))
changeTeamInfo(i, color)
writeMessage(i, said)
changeTeamInfo(i, team)
}
return PLUGIN_HANDLED_MAIN;
}
public message_sayteam(id)
{
static said[192]
read_args(said, charsmax(said))
remove_quotes(said)
if (said[0] == '%' || said[0] == '/' || said[0] == '@' || equal (said, "/"))
return PLUGIN_HANDLED
if (!ValidMessage(said, 1)) return PLUGIN_CONTINUE;
static playerTeam, playerTeamName[19]
playerTeam = get_user_team(id)
switch(playerTeam)
{
case 1: copy (playerTeamName, 6, "TE")
case 2: copy (playerTeamName, 8, "CT")
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))
new is_adm = is_user_admin(id)
new tipo[32], flags = get_user_flags(id)
if (flags & ADMIN_LEVEL_B) formatex(tipo, charsmax(tipo), "DUEÑ@")
else if (flags & ADMIN_LEVEL_E) formatex(tipo, charsmax(tipo), "SOCIO")
else if (flags & ADMIN_LEVEL_C) formatex(tipo, charsmax(tipo), "VIP")
else if (flags & ADMIN_LEVEL_H) formatex(tipo, charsmax(tipo), "Baby GirL")
else if (flags & ADMIN_LEVEL_D) formatex(tipo, charsmax(tipo), "Spammer")
if (is_user_alive (id)) {
alive = ""
} else {
alive = "*Muerto*"
}
if(is_adm) {
format(said, charsmax(said), "^1%s [%s]^3[^1%s^3] ^3NOOB. ^4%s ^1~> ^3%s :^4 %s", alive, playerTeam, Rangos[g_rango[id]], tipo, name, said)
} else {
format(said, charsmax(said), "^1%s [%s]^3[^1%s^3] ^1: %s", alive, playerTeam, Rangos[g_rango[id]], name, said)
}
static i, team[11]
for (i = 1; i <= g_maxplayers; i++) {
if (!is_user_connected(i)) continue;
get_user_name(id,name,charsmax(name))
if (get_user_team(i) == playerTeam || is_user_admin(i)) {
if (is_user_alive(id) && is_user_alive(i) || !is_user_alive(id) && !is_user_alive(i)) {
get_user_team(i, team, charsmax(team))
changeTeamInfo(i, color)
writeMessage(i, said)
changeTeamInfo(i, team)
}
}
}
return PLUGIN_HANDLED_MAIN;
}
public changeTeamInfo(player, team[]) {
message_begin(MSG_ONE, g_msgTeamInfo, _, player)
write_byte(player)
write_string(team)
message_end()
}
public writeMessage(player, message[]) {
message_begin(MSG_ONE, g_msgSayText, {0, 0, 0}, player)
write_byte(player)
write_string(message)
message_end()
}
/* ===================================
*[GUARDADO]*
=====================================*/
Guardar(id) {
formatex(szKey, charsmax(szKey), "data_rangos")
formatex(szRangos, charsmax(szRangos), "%d %d", g_frags[id], g_rango[id])
nfv_set_data(VaultRango, szKey, g_playername[id], szRangos)
}
Cargar(id) {
new g_load_c1[25], g_load_c2[25]
formatex(szKey, charsmax(szKey), "data_rangos")
if(!nfv_get_data(VaultRango, szKey, g_playername[id], szRangos, sizeof(szRangos) - 1)) return;
parse(szRangos, g_load_c1, charsmax(g_load_c1), g_load_c2, charsmax(g_load_c2))
g_frags[id] = str_to_num(g_load_c1)
g_rango[id] = str_to_num(g_load_c2)
}
/* ===================================
*[STOCKS]*
=====================================*/
// stock de chatcolor
stock chatcolor(id, const input[], any:...) {
new count = 1, players[32];
static msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "!g", "^4"); // Verde
replace_all(msg, 190, "!y", "^1"); // Default
replace_all(msg, 190, "!t", "^3"); // Color del Equipo
if (id) players[0] = id; else get_players(players, count, "ch"); {
for (new i = 0; i < count; i++) {
if (is_user_connected(players[i])) {
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}
// Stock para Saber Si el mensaje es valido
stock ValidMessage(text[], maxcount) {
static len, i, count
len = strlen(text)
count = 0
if (!len)
return false;
for (i = 0; i < len; i++) {
if (text[i] != ' ') {
count++
if (count >= maxcount)
return true;
}
}
return false;
}