Done
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <fun>
#include <cstrike>
#include <fakemeta_util>
#include <hamsandwich>
#define PLUGIN "Addons : Zombie Escape"
#define VERSION "1.0"
#define AUTHOR "Author"
#define is_valid_player(%1) (1 <= %1 <= 32)
new g_level[32], g_level_data, g_frags_level, g_ScreenFade
new g_level_max, g_level_num, g_levels[32]
new level_exp[32], g_aim_info, buffer[32]
new g_level_exp[32], g_Players, nameid[32], g_points[32]
new g_trime[32], g_MsgSync, gGrads[32]
new sound_level_up[] = { ""}
const PEV_SPEC_TARGET = pev_iuser2
public plugin_precache()
{
precache_sound( sound_level_up )
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_frags_level = register_cvar("zp_level_frags", "5")
g_level_max = register_cvar("zp_level_max", "1000")
g_aim_info = register_cvar("xp_aim_info", "1")
g_level_num = register_cvar("zp_level_number", "1")
g_level_data = nvault_open("Leveling_Save")
register_event("HLTV", "Round_Start", "a", "1=0", "2=0")
register_event("DeathMsg", "Frags_Manager", "a", "1>0")
register_event("DeathMsg", "eDeath", "a")
g_ScreenFade = get_user_msgid( "ScreenFade" )
register_event("StatusValue","show_status","b e","1=2","2!0")
register_event("StatusValue","hide_status","b e","1=1","2=0")
register_event("SendAudio", "Win_CT", "a", "2&%!MRAD_ctwin")
g_Players =get_maxplayers()
g_MsgSync = CreateHudSyncObj()
}
new const Grads[][] =
{
"Noob",
"Noob",
"Noob",
"Noob",
"Noob",
"Noob",
"Noob",
"Noob",
"Noob",
"Noob",
"Escaper",
"Escaper",
"Escaper",
"Escaper",
"Escaper",
"Escaper",
"Escaper",
"Escaper",
"Escaper",
"Escaper",
"Escaper",
"Caller",
"Caller",
"Caller",
"Caller",
"Caller",
"Caller",
"Caller",
"Caller",
"Caller",
"Caller",
"Solider",
"Solider",
"Solider",
"Solider",
"Solider",
"Solider",
"Solider",
"Solider",
"Solider",
"Solider",
"Killer",
"Killer",
"Killer",
"Killer",
"Killer",
"Killer",
"Killer",
"Killer",
"Killer",
"Killer",
"Commander",
"Commander"
}
public Round_Start()
{
for(new id=1;id<=g_Players;id++)
set_task(3.0, "Level", id)
}
public Level(id)
{
if(is_user_alive(id) )
{
g_trime[id] = false;
new n = 1;
while( n < g_level[id] )
{
n = n + 1
}
}
}
public Win_CT(id)
{
if(cs_get_user_team(id) == CS_TEAM_CT)
{
g_level_exp[id] += 5
}
}
public client_putinserver(id)
{
if(!is_user_bot(id) && is_valid_player(id))
Level_Load(id)
g_level_exp[id] = get_pcvar_num(g_frags_level)
new name[32]
g_trime[id] = false;
nameid[id] = get_user_name(id, name, sizeof name - 1)
if(is_user_alive(id))
{
g_trime[id] = false;
new n = 1;
while( n != g_level[id] )
{
n = n + 1;
}
}
if( g_level[id] == 0) g_level[id] = 1;
if( level_exp[id] == g_level[id] ) level_exp[id] = 0;
if(g_level[id] < get_pcvar_num(g_level_num))
g_levels[id] = get_pcvar_num(g_level_num);
else
{
if(g_level[id] != g_levels[id])
{
new x = 1;
while( g_level[id] > ( x * get_pcvar_num(g_level_num)) )
{
x = x + 1;
g_levels[id] = x * get_pcvar_num(g_level_num);
}
}
}
new y = 1;
while( g_level[id] != y )
{
y = y + 1;
g_level_exp[id] = y * get_pcvar_num(g_frags_level);
}
}
public hide_status(id)
{
set_hudmessage(0,0,0,0.0,0.0,0, 0.0, 0.01, 0.0, 0.0, 4)
show_hudmessage(id,"")
}
public show_status(id)
{
new name[32],pid = read_data(2)
get_user_name(pid,name,31)
switch(get_user_team(pid))
{
case 1: copy(buffer, 31, "Zombie")
case 2: copy(buffer, 31, "Human")
}
if(get_pcvar_num(g_aim_info) == 1)
{
set_hudmessage(random_num(200,150),random_num (100,50),random_num(50,25),-1.0,0.60,1, 0.01, 4.0, 0.01, 0.01, 4)
show_hudmessage(id, "%s^n[ Health : %d | Class : %s ]^n[ Grade : %s | Level : %i | Exp : %i/%i ]",name, get_user_health(pid), buffer, Grads[gGrads[pid]], g_level[pid], level_exp[pid], g_level_exp[pid], g_points[pid])
}
}
public eDeath()
{
new attacker = read_data(1)
new victim = read_data(2)
new headshot = read_data(3)
if(cs_get_user_team(attacker) != cs_get_user_team(victim))
{
g_points[attacker] += 1
}
else
{
if(attacker == victim)
{
g_points[attacker] += 0
}
else
{
if(!headshot)
g_points[attacker] += 1
else
g_points[attacker] += 1
}
}
}
public client_disconnect(id)
{
{
new name[32], player_nick[32]
player_nick[id] = get_user_name(id, name, sizeof name - 1)
if(player_nick[id] == nameid[id])
Level_Save(id)
}
Level_Save(id)
g_trime[id] = false;
}
public level_status(id)
{
new Spec
Spec = pev(id, PEV_SPEC_TARGET)
new PlayerName[32]
get_user_name(Spec, PlayerName, 31)
switch(get_user_team(id))
{
case 1: copy(buffer, 31, "Zombie")
case 2: copy(buffer, 31, "Human")
}
if(is_user_alive(id))
{
set_hudmessage(10, 180, 10, -1.0, 0.87, 0, 6.0, 1.1)
ShowSyncHudMsg(id, g_MsgSync, "[ Health : %d | Class : %s ]^n[ Grade : %s | Level : %i | Exp : %i/%i ]",get_user_health(id), buffer, Grads[gGrads[id]], g_level[id], level_exp[id], g_level_exp[id], g_points[id])
}
else
switch(get_user_team(Spec))
{
case 1: copy(buffer, 31, "Zombie")
case 2: copy(buffer, 31, "Human")
}
if(is_user_alive(Spec))
{
set_hudmessage(200, 30, 200, -1.0, 0.79, 0, 6.0, 1.1)
ShowSyncHudMsg(id, g_MsgSync, "Spectating: %s ^n[ Health : %d | Class : %s ]^n[ Grade : %s | Level : %i | Exp : %i/%i ]",PlayerName, get_user_health(Spec), buffer, Grads[gGrads[id]], g_level[Spec], level_exp[Spec], g_level_exp[Spec], g_points[Spec])
}
}
public Level_Save(id)
{
new key[64], data[256]
new name[33]
get_user_name(id,name,32)
format(key, 63, "%s-/", name)
format(data, 255, "%i#", g_level[id], level_exp[id], g_points[id], gGrads[id])
nvault_set(g_level_data, key, data)
return PLUGIN_CONTINUE;
}
public Level_Load(id)
{
new key[64], data[256]
new name[33]
get_user_name(id,name,32)
format(key, 63, "%s-/", name)
format(data, 255, "%i# %i# %d# %s#", g_level[id], level_exp[id], g_points[id], gGrads[id])
nvault_get(g_level_data, key, data, 255)
replace_all(data, 255, "#", " ")
new givelevel[32]
parse(data, givelevel, 31)
g_level[id] = str_to_num(givelevel)
set_task(1.0 ,"level_status", id, _, _, "b")
return PLUGIN_CONTINUE;
}
public Frags_Manager()
{
new aname[32], attacker; attacker = read_data(1)
new y; y = 1;
get_user_name(attacker, aname, sizeof aname - 1)
if( ( level_exp[attacker] >= (g_level_exp[attacker] - 1) ) && (g_level[attacker] <= get_pcvar_num(g_level_max)) && is_user_alive(attacker) )
{
g_level[attacker] = g_level[attacker] + 1;
level_exp[attacker] = 0;
while( g_level[attacker] != y )
{
y = y + 1;
g_level_exp[attacker] = y * get_pcvar_num(g_frags_level);
}
message_begin(MSG_ONE_UNRELIABLE, g_ScreenFade, _, attacker)
write_short(1<<12) // duration
write_short(1) // hold time
write_short(0x0000) // fade type
write_byte(1) // red
write_byte(200) // green
write_byte(0) // blue
write_byte(205) // alpha
message_end()
emit_sound(attacker, CHAN_STREAM, sound_level_up, 1.0, ATTN_NORM, 0, PITCH_HIGH )
set_hudmessage(0, 200, 0, 0.65, 0.5, 0, 0.0, 3.0, 2.0, 1.0, -1)
show_hudmessage(0, "%s Has Cut Down %i Level", aname, g_level[attacker])
Level_Save(attacker);
}
else
{
if(g_level[attacker] == get_pcvar_num(g_level_max))
ChatColor(attacker, "!nYou Have Reached A Maximum Level: ^4%i", g_level[attacker] )
level_exp[attacker] = level_exp[attacker] + 1;
Level_Save(attacker);
}
}
stock ChatColor(const id, const input[], any:...)
{
new count = 1, players[ 32 ]
static msg[ 191 ]
vformat( msg, 190, input, 3 )
replace_all( msg, 190, "!g", "^4" )
replace_all( msg, 190, "!y", "^1" )
replace_all( msg, 190, "!t", "^3" )
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( )
}
}
}
}