05/09/2014, 11:41 PM
(Última modificación: 15/06/2020, 04:37 AM por kikizon2. Edited 2 times in total.)
Guia definitiva de Sistemas de Niveles (Zombie Plague y Normal)
A tomar en cuenta:
- La lista se estara actualizando constantemente para agregar diferentes sistemas de subida de nivel, se hara la version para ZP, y la version normal.
- Los titulos de sistemas tendran diferentes colores para diferenciar dificultad de subida de nivel: VERDE = Facil | Naranja: Medio | Rojo = Dificil
- Los adjuntos estaran al final de la lista.
- Estos codigos fueron creados en la version AMX 1.9.0, deberia funcionar en AMX 1.8.3. No se dara soporte a versiones anteriores.
- Tema original: AQUI
1.- Sistema de niveles + resets por daño acumulado:
Zombie Plague:
Paso 1 - Declarar variables:
- 1.1 Declarar:
Código PHP:
#define MAX_LEVEL 30 // Maximo nivel
#define DEFAULT_DAMAGE 1200 // Daño requerido por default
// Si no quieres HappyHour Borra/Comenta la siguiente linea
#define HAPPYHOUR
#if defined HAPPYHOUR
new bool:g_bHappyTime, g_iHappyMulti;
enum _:__HappyData { HH_HOUR[3], HH_DAMAGE, HH_MULTI };
new const _HappyHour[][__HappyData] =
{
// HORA // DAÑO REQUERIDO // MULTIPLICADOR
{ "00", 700, 2 },
{ "04", 400, 3 },
{ "15", 100, 1 }
}
#endif
/*
Ejemplos de exp requerida:
Nivel 0: 9
Nivel 1: 12
Nivel 2: 15
Formula:
(N + 3) x 3
Donde N es el nivel actual
*/
#define RequiredExp(%1) (%1 + 3 * 3)
new g_iDamage[33], g_iExp[33], g_iLevel[33], g_iReset[33];
new cvar_exp, g_iDefaultDamage;
- 1.2 Funcion extra en Plugin init:
Buscamos la funcion:
Código PHP:
public plugin_init()
y dentro agregamos las siguientes lineas:
Código PHP:
register_clcmd("say /reset", "FuncReset");
cvar_exp = register_cvar("exp_damage", "1"); // Exp al alcanzar el daño requerido
g_iDefaultDamage = DEFAULT_DAMAGE;
-1.3 Funcion extra en round_start:
Buscamos la funcion:
Código PHP:
public round_start()
y dentro agregamos las siguientes lineas:
Código PHP:
#if defined HAPPYHOUR
RefreshHH();
#endif
Paso 2 - Formatear variables:
- 2.1 Buscamos la siguiente funcion:
Código PHP:
reset_vars(id, resetall)
-2.2 Dentro de la funcion, buscamos la siguiente condicion:
Código PHP:
if (resetall)
{
-2.3 Reseteamos las variables dentro de esa condicion
Código PHP:
g_iDamage[id] = g_iExp[id] = g_iLevel[id] = g_iReset[id] = 0;
Paso 3 - Funciones en TakeDamage:
- 3.1 Buscamos la funcion:
Código PHP:
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
- 3.2 Buscamos la condicion:
Código PHP:
if(!g_zombie[attacker])
{
- 3.3 IMPORTANTE (Si quieres que el daño solo sea para humanos, ingresa el codigo dentro de la condicion, si quieres que aplique tambien para zombies, ingresa el codigo antes de la condicion anterior)
Código PHP:
g_iDamage[attacker] += floatround(damage);
while(g_iDamage[attacker] >= g_iDefaultDamage)
{
g_iDamage[attacker] -= g_iDefaultDamage;
SetExp(attacker, get_pcvar_num(cvar_exp));
}
Paso 4 - Agregar demas funciones:
- 4.1: Pasamos al final del plugin y agregamos el siguiente codigo:
Código PHP:
SetExp(index, iExp)
{
if(!index || !is_user_connected(index) || g_iLevel[index] >= MAX_LEVEL) return;
static iLevel; iLevel = g_iLevel[index];
#if defined HAPPYHOUR
g_iExp[index] += (iExp*g_iHappyMulti);
#else
g_iExp[index] += iExp;
#endif
while(g_iExp[index] >= RequiredExp(g_iLevel[index]) && g_iLevel[index] < MAX_LEVEL) ++g_iLevel[index];
if(g_iLevel[index] > iLevel) client_print_color(index, print_team_default, "Felicidades! Subiste al nivel ^4%d ^1:D", g_iLevel[index]);
}
public FuncReset(index)
{
if(g_iLevel[index] < MAX_LEVEL)
{
client_print_color(index, print_team_default, "Necesitas ser nivel ^4%d ^1para poder resetear!", MAX_LEVEL);
return PLUGIN_HANDLED;
}
++g_iReset[index];
g_iExp[index] = g_iLevel[index] = 0;
client_print_color(index, print_team_default, "Felicidades! Reseteaste tu cuenta, ahora eres reset ^4%d", g_iReset[index]);
return PLUGIN_HANDLED;
}
#if defined HAPPYHOUR
RefreshHH()
{
g_bHappyTime = false;
g_iDefaultDamage = DEFAULT_DAMAGE;
g_iHappyMulti = 1;
static i, current_hour[3]; get_time("%H", current_hour, 2);
for( i = 0 ; i < sizeof _HappyHour ; ++i )
{
if(equal(_HappyHour[i][HH_HOUR], current_hour))
{
g_bHappyTime = true;
g_iHappyMulti = _HappyHour[i][HH_MULTI];
g_iDefaultDamage = _HappyHour[i][HH_DAMAGE];
client_print_color(0, print_team_default, "^4HORA FELIZ ACTIVA!!! ^3Daño requerido: ^1%d ^3Multiplicador: ^1%d", g_iDefaultDamage, g_iHappyMulti);
break;
}
}
}
#endif
Paso 5 - Editar el HUD:
Buscamos la funcion:
Código PHP:
public ShowHUD(taskid)
y la reemplazamos por la siguiente:
Código PHP:
public ShowHUD(taskid)
{
static id
id = ID_SHOWHUD;
if (!g_isalive[id])
{
id = pev(id, PEV_SPEC_TARGET)
if (!g_isalive[id]) return;
}
static class[32], red, green, blue
if (g_zombie[id])
{
red = 200
green = 250
blue = 0
if (g_nemesis[id])
formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_NEMESIS")
else
copy(class, charsmax(class), g_zombie_classname[id])
}
else
{
red = 255
green = 255
blue = 0
if (g_survivor[id])
formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_SURVIVOR")
else
copy(class, charsmax(class), g_human_classname[id])
}
if (id != ID_SHOWHUD)
{
set_hudmessage(255, 255, 255, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "%L: %s^nHP: %d|%L: %s |%L: %d|Nivel: %d|Reset: %d", ID_SHOWHUD, "SPECTATING", g_playername[id], pev(id, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[id], g_iLevel[id], g_iReset[id])
}
else
{
set_hudmessage(red, green, blue, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
#if defined HAPPYHOUR
ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "%L: %d|%L: %s|%L %d|Nivel: %d/%d|Exp: %d/%d|Dmg: %d/%d|Reset: %d|HORA FELIZ: %s", id, "ZOMBIE_ATTRIB1", pev(ID_SHOWHUD, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[ID_SHOWHUD], g_iLevel[id], MAX_LEVEL, g_iExp[id], RequiredExp(g_iLevel[id]), g_iDamage[id], g_iDefaultDamage, g_iReset[id], g_bHappyTime ? "Activada" : "Desactivada")
#else
ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "%L: %d|%L: %s|%L %d|Nivel: %d/%d|Exp: %d/%d|Dmg: %d/%d|Reset: %d|", id, "ZOMBIE_ATTRIB1", pev(ID_SHOWHUD, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[ID_SHOWHUD], g_iLevel[id], MAX_LEVEL, g_iExp[id], RequiredExp(g_iLevel[id]), g_iDamage[id], g_iDefaultDamage, g_iReset[id])
#endif
}
}
Normal:
Código PHP:
#include <amxmodx>
#include <hamsandwich>
#define MAX_LEVEL 30 // Maximo nivel
#define DEFAULT_DAMAGE 1200 // Daño requerido por default
#define TASK_HUD 134763
#define ID_HUD (task_id - TASK_HUD)
// Si no quieres HappyHour Borra/Comenta la siguiente linea
#define HAPPYHOUR
#if defined HAPPYHOUR
new bool:g_bHappyTime, g_iHappyMulti;
enum _:__HappyData { HH_HOUR[3], HH_DAMAGE, HH_MULTI };
new const _HappyHour[][__HappyData] =
{
// HORA // DAÑO REQUERIDO // MULTIPLICADOR
{ "00", 700, 2 },
{ "04", 400, 3 },
{ "15", 100, 1 }
}
#endif
/*
Ejemplos de exp requerida:
Nivel 0: 9
Nivel 1: 12
Nivel 2: 15
Formula:
(N + 3) x 3
Donde N es el nivel actual
*/
#define RequiredExp(%1) (%1 + 3 * 3)
new g_iDamage[33], g_iExp[33], g_iLevel[33], g_iReset[33];
new g_iSync, cvar_exp, g_iDefaultDamage;
#define VERSION "1.0"
public plugin_init()
{
register_plugin("Niveles + Resets por daño", VERSION, "kikizon / LSSTUDIOS.XYZ");
RegisterHam(Ham_TakeDamage, "player", "PlayerDamagePost", true);
register_clcmd("say /reset", "FuncReset");
cvar_exp = register_cvar("exp_damage", "1");
g_iSync = CreateHudSyncObj();
g_iDefaultDamage = DEFAULT_DAMAGE;
#if defined HAPPYHOUR
register_event("HLTV", "RoundStart", "a", "1=0", "2=0");
#endif
}
public client_putinserver(index)
{
g_iDamage[index] = g_iExp[index] = g_iLevel[index] = g_iReset[index] = 0;
set_task(1.0, "LevelHud", index+TASK_HUD, .flags="b");
}
public client_disconnected(index) remove_task(index+TASK_HUD);
public PlayerDamagePost(victim, inflictor, attacker, Float:damage, damage_type)
{
if(!attacker || !is_user_connected(attacker) || !is_user_connected(victim) || attacker == victim) return;
g_iDamage[attacker] += floatround(damage);
while(g_iDamage[attacker] >= g_iDefaultDamage)
{
g_iDamage[attacker] -= g_iDefaultDamage;
SetExp(attacker, get_pcvar_num(cvar_exp));
}
}
SetExp(index, iExp)
{
if(!index || !is_user_connected(index) || g_iLevel[index] >= MAX_LEVEL) return;
static iLevel; iLevel = g_iLevel[index];
#if defined HAPPYHOUR
g_iExp[index] += (iExp*g_iHappyMulti);
#else
g_iExp[index] += iExp;
#endif
while(g_iExp[index] >= RequiredExp(g_iLevel[index]) && g_iLevel[index] < MAX_LEVEL) ++g_iLevel[index];
if(g_iLevel[index] > iLevel) client_print_color(index, print_team_default, "Felicidades! Subiste al nivel ^4%d ^1:D", g_iLevel[index]);
}
public FuncReset(index)
{
if(g_iLevel[index] < MAX_LEVEL)
{
client_print_color(index, print_team_default, "Necesitas ser nivel ^4%d ^1para poder resetear!", MAX_LEVEL);
return PLUGIN_HANDLED;
}
++g_iReset[index];
g_iExp[index] = g_iLevel[index] = 0;
client_print_color(index, print_team_default, "Felicidades! Reseteaste tu cuenta, ahora eres reset ^4%d", g_iReset[index]);
return PLUGIN_HANDLED;
}
public LevelHud(task_id)
{
if(!is_user_alive(ID_HUD)) return;
set_hudmessage(250, 250, 250, 0.0, 0.95);
#if defined HAPPYHOUR
ShowSyncHudMsg(ID_HUD, g_iSync, "Daño acumulado: %d de %d - Exp: %d de %d | Nivel: %d de %d - Reset %d - Hora Feliz: %s", g_iDamage[ID_HUD], g_iDefaultDamage, g_iExp[ID_HUD], RequiredExp(g_iLevel[ID_HUD]), g_iLevel[ID_HUD], MAX_LEVEL, g_iReset[ID_HUD], g_bHappyTime ? "Activada" : "Desactivada");
#else
ShowSyncHudMsg(ID_HUD, g_iSync, "Daño acumulado: %d de %d - Exp: %d de %d | Nivel: %d de %d - Reset %d", g_iDamage[ID_HUD], g_iDefaultDamage, g_iExp[ID_HUD], RequiredExp(g_iLevel[ID_HUD]), g_iLevel[ID_HUD], MAX_LEVEL, g_iReset[ID_HUD]);
#endif
}
#if defined HAPPYHOUR
public RoundStart(index) RefreshHH();
RefreshHH()
{
g_bHappyTime = false;
g_iDefaultDamage = DEFAULT_DAMAGE;
g_iHappyMulti = 1;
static i, current_hour[3]; get_time("%H", current_hour, 2);
for( i = 0 ; i < sizeof _HappyHour ; ++i )
{
if(equal(_HappyHour[i][HH_HOUR], current_hour))
{
g_bHappyTime = true;
g_iHappyMulti = _HappyHour[i][HH_MULTI];
g_iDefaultDamage = _HappyHour[i][HH_DAMAGE];
client_print_color(0, print_team_default, "^4HORA FELIZ ACTIVA!!! ^3Daño requerido: ^1%d ^3Multiplicador: ^1%d", g_iDefaultDamage, g_iHappyMulti);
break;
}
}
}
#endif
2.- Sistema de niveles por frags e infecciones (Niveles "infinitos" Sin reset)
Zombie Plague:
Paso 1 - Declarar variables:
- 1.1 Declaramos:
Código PHP:
/*
Ejemplos de exp requerida:
Nivel 0: 9
Nivel 1: 12
Nivel 2: 15
Formula:
(N + 3) x 3
Donde N es el nivel actual
PD: Las formulas son distintas, para poder manejar distintos valores
en caso de que los frags o infecciones se hagan mas dificiles.
*/
#define RequiredFrags(%1) (%1 * 3 * 3)
#define RequiredInfects(%1) (%1 * 2 * 2)
new g_iFrags[33], g_iInfects[33], g_iLevel[33];
new cvar_frags_by_kill, cvar_frags_by_infect;
- 1.2 Codigo extra en plugin_init()
Código PHP:
cvar_frags_by_kill = register_cvar("frags_by_kill", "1");
cvar_frags_by_infect = register_cvar("frags_by_infect", "1");
Paso 2 - Formatear variables:
- 2.1 Buscamos la siguiente funcion:
Código PHP:
reset_vars(id, resetall)
-2.2 Dentro de la funcion, buscamos la siguiente condicion:
Código PHP:
if (resetall)
{
-2.3 Reseteamos las variables dentro de esa condicion:
Código PHP:
g_iFrags[id] = g_iInfects[id] = g_iLevel[id] = 0;
Paso 3 - Funciones en Player Killed y Player Infected:
- 2.1 Buscamos la siguiente funcion:
Código PHP:
public fw_PlayerKilled(victim, attacker, shouldgib)
-2.2 Agregamos el siguiente codigo al final de la funcion:
Código PHP:
SetFrags(attacker, get_pcvar_num(cvar_frags_by_kill), 0);
-2.3 Buscamos la siguiente funcion:
Código PHP:
zombieme(id, infector, nemesis, silentmode, rewards)
-2.4 Dentro de la funcion buscamos la siguiente condicion:
Código PHP:
if (rewards && infector)
{
-2.5 Dentro de la condicion agregamos el siguiente codigo:
Código PHP:
SetFrags(infector, 0, get_pcvar_num(cvar_frags_by_infect));
Paso 4 - Agregar demas funciones:
-4.1 Pasamos al final del plugin y agregamos el siguiente codigo:
Código PHP:
SetFrags(index, iFrags, iInfects)
{
if(!index || !is_user_connected(index)) return;
g_iFrags[index] += iFrags;
g_iInfects[index] += iInfects;
static iLevel; iLevel = g_iLevel[index];
while(g_iFrags[index] >= RequiredFrags(g_iLevel[index]) && g_iInfects[index] >= RequiredInfects(g_iLevel[index])) ++g_iLevel[index];
if(g_iLevel[index] > iLevel) client_print_color(index, print_team_default, "Felicidades! Subiste al nivel ^4%d", g_iLevel[index]);
}
Paso 5 - Editar HUD:
-5.1 Buscar la funcion:
Código PHP:
public ShowHUD(taskid)
-5.2 Reemplazar la funcion, por esta:
Código PHP:
// Show HUD Task
public ShowHUD(taskid)
{
static id
id = ID_SHOWHUD;
// Player died?
if (!g_isalive[id])
{
// Get spectating target
id = pev(id, PEV_SPEC_TARGET)
// Target not alive
if (!g_isalive[id]) return;
}
// Format classname
static class[32], red, green, blue
if (g_zombie[id]) // zombies
{
red = 200
green = 250
blue = 0
if (g_nemesis[id])
formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_NEMESIS")
else
copy(class, charsmax(class), g_zombie_classname[id])
}
else // humans
{
red = 0
green = 0
blue = 255
if (g_survivor[id])
formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_SURVIVOR")
else
formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_HUMAN")
}
// Spectating someone else?
if (id != ID_SHOWHUD)
{
// Show name, health, class, and ammo packs
set_hudmessage(255, 255, 255, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "%L %s^nHP: %d - %L %s - %L %d - Frags: %s - Infecciones: %s - Nivel: %d", ID_SHOWHUD, "SPECTATING", g_playername[id], pev(id, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[id], g_iFrags[id] >= RequiredFrags(g_iLevel[id]) ? fmt("COMPLETADO") : fmt("%d de %d", g_iFrags[id], RequiredFrags(g_iLevel[id])), g_iInfects[id] >= RequiredInfects(g_iLevel[id]) ? fmt("COMPLETADO") : fmt("%d de %d", g_iInfects[id], RequiredInfects(g_iLevel[id])), g_iLevel[id])
}
else
{
// Show health, class and ammo packs
set_hudmessage(red, green, blue, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "%L: %d - %L %s - %L %d - Frags: %s - Infecciones: %s - Nivel: %d", id, "ZOMBIE_ATTRIB1", pev(ID_SHOWHUD, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[ID_SHOWHUD], g_iFrags[ID_SHOWHUD] >= RequiredFrags(g_iLevel[ID_SHOWHUD]) ? fmt("COMPLETADO") : fmt("%d de %d", g_iFrags[ID_SHOWHUD], RequiredFrags(g_iLevel[ID_SHOWHUD])), g_iInfects[ID_SHOWHUD] >= RequiredInfects(g_iLevel[ID_SHOWHUD]) ? fmt("COMPLETADO") : fmt("%d de %d", g_iInfects[ID_SHOWHUD], RequiredInfects(g_iLevel[ID_SHOWHUD])), g_iLevel[ID_SHOWHUD])
}
}
Normal (Solo frags):
Código PHP:
#include <amxmodx>
#include <hamsandwich>
#define TASK_HUD 13247
#define ID_HUD (task_id - TASK_HUD)
/*
Ejemplos de exp requerida:
Nivel 0: 9
Nivel 1: 12
Nivel 2: 15
Formula:
(N + 3) x 3
Donde N es el nivel actual
*/
#define RequiredFrags(%1) (%1 * 3 * 3)
#define VERSION "1.0"
new g_iFrags[33], g_iLevel[33];
new g_iSync, cvar_frags_by_kill;
public plugin_init()
{
register_plugin("Niveles por frags", VERSION, "kikizon / LSSTUDIOS.XYZ");
RegisterHam(Ham_Killed, "player", "PlayerKilledPost", true);
cvar_frags_by_kill = register_cvar("frags_by_kill", "1");
g_iSync = CreateHudSyncObj();
}
public client_putinserver(index)
{
g_iFrags[index] = g_iLevel[index] = 0;
set_task(1.0, "LevelHud", index+TASK_HUD, .flags="b");
}
public client_disconnected(index) remove_task(index+TASK_HUD);
public PlayerKilledPost(victim, attacker)
{
if(!attacker || !is_user_connected(attacker) || !is_user_connected(victim) || victim == attacker)
SetFrags(attacker, get_pcvar_num(cvar_frags_by_kill));
}
SetFrags(index, iFrags)
{
if(!index || !is_user_connected(index)) return;
g_iFrags[index] += iFrags;
static iLevel; iLevel = g_iLevel[index];
while(g_iFrags[index] >= RequiredFrags(g_iLevel[index])) ++g_iLevel[index];
if(g_iLevel[index] > iLevel) client_print_color(index, print_team_default, "Felicidades! Subiste al nivel ^4%d", g_iLevel[index]);
}
public LevelHud(task_id)
{
if(!is_user_alive(ID_HUD)) return;
set_hudmessage(200, 200, 200, 0.0, 0.95);
ShowSyncHudMsg(ID_HUD, g_iSync, "Frags: %d de %d - Nivel: %d", g_iFrags[ID_HUD], RequiredFrags(g_iLevel[ID_HUD]), g_iLevel[ID_HUD]);
}
Adjuntos del tema (Modos normales):
Niveles por daño requerido:
Descargar AMXX / NORMAL_pordamage.sma (Tamaño: 4.16 KB / Descargas: 108)
Niveles por frags:
Descargar AMXX / NORMAL_porfrags.sma (Tamaño: 1.68 KB / Descargas: 48)