Post by nikolay on Jan 30, 2015 21:29:38 GMT
I use this custom_level
the problem is that reserves levels collected in such a way that if someone deletes cs and install cs again no have XP / level
/*
-----------------------------------------------
Copyright (C) 2014 excalibur.007 + zmd94
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-----------------------------------------------
*/
//Uncomment 'IM_USING_ZP50' if your server is running ZP50 and above
//#define IM_USING_ZP50
//Uncomment 'CUSTOM_CHAT' if your want to use custom chat
//#define CUSTOM_CHAT
//Uncomment 'DATA_EXPIRED' if your want to enable data expired function
//#define DATA_EXPIRED
//Uncomment 'CHANGE_NAME' if your want to enable player to change their name
//#define CHANGE_NAME
// if you are using this Custom Level for ZPA,
// just change line below into #include <zombie_plague_advance>
#include <zombieplague>
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <nvault_util>
#include <nvault>
#include <fun>
#if defined IM_USING_ZP50
#include <zp50_core>
#include <zp50_class_zombie>
#endif
new const VERSION[] = "2.4"
new const RANKS[][]=
{
"New", // 0
"Killer", // 1
"Good", // 2
"Ultra", // 3
"Staff", // 4
"Gamer", // 5
"Master", // 6
"Major", // 7
"Predator", // 8
"Major Predator", // 9
"Fan", // 10
"Energy Player", // 11
"No Controll", // 12
"Bigger", // 13
"Get free AP", // 14
"Get Free VIP", // 15
"Get Free Admin", // 16
"Unique", // 17
"Fieldmarchall" // 18
}
new const EXP[] =
{
0, // 0
300, // 1
950, // 2
2500, // 3
3500, // 4
4500, // 5
5000, // 6
6500, // 7
7500, // 8
8500, // 9
9500, // 10
10000, // 11
12000, // 12
13000, // 13
14000, // 14
20000, // 15
90000, // 16
1000000, // 17
200000000 // 18
}
#define ADMIN_FLAG ADMIN_IMMUNITY
#define TASK_SHOWINFORM 1994
#define ID_SHOWINFORM (taskid - TASK_SHOWINFORM)
#define TOPLEVEL 15
const PEV_SPEC_TARGET = pev_iuser2
enum _:VaultData
{
VD_Key[64],
VD_Value
};
new g_szTopMotd[1024]
new cvar_e1, cvar_e2, cvar_e3, cvar_e4, cvar_e5, cvar_e6, cvar_e7, cvar_e8
new cvar_save_name, cvar_save_steam
new cvar_level_red, cvar_level_green, cvar_level_blue, cvar_score_red, cvar_score_green, cvar_score_blue
new cvar_hud, cvar_hud_position1, cvar_hud_position2, cvar_connect_message
new cvar_bonus, cvar_health_bonus, cvar_armor_bonus, cvar_apamount
new cvar_xp, cvar_zxp, cvar_hsxp, cvar_level_bonus, cvar_icon, cvar_icon_time, cvar_kill_survivor, cvar_kill_nemesis
new cached_xp, cached_zxp, cached_hsxp, cached_levelxp, cached_icon, cached_survivor_xp, cached_nemesis_xp
new Float:cached_icon_time
new iLevel[33], iXP[33], iSprite[20]
new iDamage[33][33], iKilledZombie[33][33]
new iSteamID[33][32], iName[33][32]
new g_zombiescore, g_humanscore
new g_iVault, g_SyncHud, g_msgSayText
#if defined IM_USING_ZP50
new iMaxHealth[33]
new cvar_assistxp, cvar_divide
new cached_assistxp, cached_divide
#endif
#if defined DATA_EXPIRED
new cvar_expired
#endif
public plugin_precache()
{
new szFile[35]
for(new i = 0; i < sizeof(RANKS); i++)
{
formatex(szFile, charsmax(szFile), "sprites/zombie_plague/level/%i.spr", i)
iSprite[i] = precache_model(szFile)
}
}
public plugin_init()
{
register_plugin("[ZP] Addon: Custom Level", VERSION, "excalibur.007 + zmd94")
register_dictionary("custom_level.txt")
#if defined CUSTOM_CHAT
register_clcmd("say", "hook_say")
register_clcmd("say_team", "hook_say_team")
#endif
register_clcmd("nightvision" , "custom_menu")
register_clcmd("say /clnext", "show_stats")
register_clcmd("say_team /clnext", "show_stats")
register_clcmd("say /cltop", "show_top")
register_clcmd("say_team /cltop", "show_top")
register_clcmd("say /savecl", "save_data")
register_clcmd("say_team /savecl", "save_data")
register_clcmd("free_give","cl_give", ADMIN_FLAG, "Enable to give free EXP")
register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
register_event("Damage", "event_damage", "be", "2!0", "3=0", "4!0")
register_event("DeathMsg", "event_deathMsg", "a", "1>0")
register_event("StatusValue", "event_StatusValue", "be", "1=2", "2!0")
register_event("TextMsg", "event_Restart", "a", "2&#Game_C", "2&#Game_w")
RegisterHam(Ham_Spawn, "player", "fw_PlayerRespawn", 1)
#if defined CHANGE_NAME
register_forward( FM_ClientUserInfoChanged, "FwdClientUserInfoChanged" )
#endif
cvar_save_name = register_cvar("zp_save_name", "1") // Save the EXP via player name
cvar_save_steam = register_cvar("zp_save_steam", "0") // Save the EXP via player steam ID
#if defined DATA_EXPIRED
cvar_expired = register_cvar("zp_data_expired", "5") // This will remove all entries in the vault that are X days old
#endif
cvar_connect_message = register_cvar("zp_connect_message", "1") // Enable connect message
cvar_xp = register_cvar("zp_human_xp", "5") // Amount of EXP gain from killing a zombie without headshot
cvar_zxp = register_cvar("zp_zombie_xp", "1") // Amount of EXP gain from killing a human
cvar_hsxp = register_cvar("zp_level_hsxp", "7") // Amount of EXP gain from killing a zombie with headshot
cvar_icon = register_cvar("zp_level_icon", "1") // Enable level icon
cvar_icon_time = register_cvar("zp_level_icon_time", "1.5") // The time for the icon to stay displaying
cvar_e1 = register_cvar("zp_enable_level_bonus", "1") // Enable level bonus
cvar_level_bonus = register_cvar("zp_level_up_bonus", "5") // Amount of EXP gain when level up
cvar_hud = register_cvar("zp_level_hud", "1") // Enable level hud information
cvar_level_red = register_cvar("zp_level_red_color", "255") // 0 is none 255 is full effect
cvar_level_green = register_cvar("zp_level_green_color", "0") // 0 is none 255 is full effect
cvar_level_blue = register_cvar("zp_level_blue_color", "0") // 0 is none 255 is full effect
cvar_hud_position1 = register_cvar("zp_hud_position1", "0") // The position of hud information is in the right
cvar_hud_position2 = register_cvar("zp_hud_position2", "1") // The position of hud information is in the left
cvar_bonus = register_cvar("zp_level_bonus", "1") // Enable health and armor reward
cvar_health_bonus = register_cvar("zp_health_amount", "50") // The values of health reward
cvar_armor_bonus = register_cvar("zp_armor_amount", "25") // The values of armor reward
cvar_e2 = register_cvar("zp_ammo_packs", "1") // Enable ammo packs reward when level up
cvar_apamount = register_cvar("zp_ammo_packs_amount", "25") // The values of ammo packs reward
cvar_e3 = register_cvar("zp_show_hit_recieved", "1") // Enable showing recieved damage
cvar_e4 = register_cvar("zp_show_hit_dealt", "1") // Enable showing dealt damage
cvar_e5 = register_cvar("zp_show_score", "1") // Enable showing score for zombie and human
cvar_score_red = register_cvar("zp_score_red_color", "255") // 0 is none 255 is full effect
cvar_score_green = register_cvar("zp_score_green_color", "0") // 0 is none 255 is full effect
cvar_score_blue = register_cvar("zp_score_blue_color", "0") // 0 is none 255 is full effect
cvar_e6 = register_cvar("zp_human_win", "1") // Enable human to be a winner if nobody win
cvar_e7 = register_cvar("zp_survivor_kill_bonus", "1") // Enable kill bonus when killing survivor
cvar_kill_survivor = register_cvar("zp_survivor_bonus_amount", "1") // Then amount of EXP bonus by killing survivor
cvar_e8 = register_cvar("zp_nemesis_kill_bonus", "1") // Enable kill bonus when killing nemesis
cvar_kill_nemesis = register_cvar("zp_nemesis_bonus_amount", "1") // Then amount of EXP bonus by killing nemesis
#if defined IM_USING_ZP50
cvar_assistxp = register_cvar("zp_level_assistxp", "2") // Amount of EXP gain from assisting a non-zombie killer.
cvar_divide = register_cvar("zp_level_assisthpdivide", "5") // Amount of damage [Zombie Max health / CVAR] needed to get an assist
#endif
g_SyncHud = CreateHudSyncObj()
g_iVault = nvault_open("custom_level")
g_msgSayText = get_user_msgid("SayText")
if(g_iVault == INVALID_HANDLE)
set_fail_state("Vault file error")
#if defined CUSTOM_CHAT
register_message(g_msgSayText, "message_SayText")
#endif
FormatTop(TOPLEVEL)
}
public plugin_cfg()
{
new cfgdir[32]
get_configsdir(cfgdir, charsmax(cfgdir))
server_cmd("exec %s/cl_system.cfg", cfgdir)
cached_xp = get_pcvar_num(cvar_xp)
cached_zxp = get_pcvar_num(cvar_zxp)
cached_hsxp = get_pcvar_num(cvar_hsxp)
cached_levelxp = get_pcvar_num(cvar_level_bonus)
cached_icon = get_pcvar_num(cvar_icon)
cached_icon_time = get_pcvar_float(cvar_icon_time)
cached_survivor_xp = get_pcvar_num(cvar_kill_survivor)
cached_nemesis_xp = get_pcvar_num(cvar_kill_nemesis)
#if defined IM_USING_ZP50
cached_assistxp = get_pcvar_num(cvar_assistxp)
cached_divide = get_pcvar_num(cvar_divide)
#endif
#if defined DATA_EXPIRED
nvault_prune(g_iVault , 0 , get_systime() - (86400 * get_pcvar_num(cvar_expired)));
#endif
}
public plugin_end()
{
nvault_close(g_iVault)
}
public zp_round_ended(iTeam)
{
switch(iTeam)
{
case WIN_ZOMBIES:
{
if (get_pcvar_num(cvar_e5))
{
g_zombiescore ++
}
}
case WIN_HUMANS:
{
if (get_pcvar_num(cvar_e5))
{
g_humanscore ++
}
}
case WIN_NO_ONE:
{
if (get_pcvar_num(cvar_e6))
{
g_humanscore ++
}
}
}
}
public client_putinserver(id)
{
if (get_pcvar_num(cvar_e5))
{
set_task(5.0, "ShowScore", 0, "", 0, "b")
}
if(is_user_connected(id))
{
LoadData(id)
if (get_pcvar_num(cvar_hud))
{
set_task(1.0, "ShowHUD", id+TASK_SHOWINFORM, _, _, "b")
}
if (get_pcvar_num(cvar_connect_message))
{
new szName[32]
get_user_name(id, szName, charsmax(szName))
print_colored(0, "!g[CL]!t %L", LANG_PLAYER, "CONNECT_MESSAGE", szName, RANKS[iLevel[id]], iXP[id])
}
}
}
public ShowHUD(taskid)
{
new player = ID_SHOWINFORM
// Player dead?
if (!is_user_alive(player))
{
// Get spectating target
player = pev(player, PEV_SPEC_TARGET)
// Target not alive
if (!is_user_alive(player))
return;
}
new level_red, level_green, level_blue
level_red = get_pcvar_num(cvar_level_red)
level_green = get_pcvar_num(cvar_level_green)
level_blue = get_pcvar_num(cvar_level_blue)
// Spectating someone else?
if (player != ID_SHOWINFORM)
{
new iSpecName[32]
get_user_name(player, iSpecName, charsmax(iSpecName))
if (get_pcvar_num(cvar_hud_position1))
{
if(iLevel[ID_SHOWINFORM] == 18)
{
set_hudmessage(level_red, level_green, level_blue, 0.75, 0.28, 0, 6.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(ID_SHOWINFORM, g_SyncHud,"[Spectating: %s] ^n[Level: Complete] ^n[EXP: Complete]", iSpecName)
}
else
{
set_hudmessage(level_red, level_green, level_blue, 0.01, 0.28, 0, 6.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(ID_SHOWINFORM, g_SyncHud,"[Spectating: %s] ^n[Level: %s] ^n[EXP: %d/ %d]", iSpecName, RANKS[iLevel[player]], iXP[player], EXP[iLevel[player] + 1])
}
}
if (get_pcvar_num(cvar_hud_position2))
{
if(iLevel[ID_SHOWINFORM] == 18)
{
set_hudmessage(level_red, level_green, level_blue, 0.75, 0.28, 0, 6.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(ID_SHOWINFORM, g_SyncHud,"[Spectating: %s] ^n[Level: Complete] ^n[EXP: Complete]", iSpecName)
}
else
{
set_hudmessage(level_red, level_green, level_blue, 0.75, 0.28, 0, 6.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(ID_SHOWINFORM, g_SyncHud,"[Spectating: %s] ^n[Level: %s] ^n[EXP: %d/ %d]", iSpecName, RANKS[iLevel[player]], iXP[player], EXP[iLevel[player] + 1])
}
}
}
else
{
if (get_pcvar_num(cvar_hud_position1))
{
if(iLevel[ID_SHOWINFORM] == 18)
{
set_hudmessage(level_red, level_green, level_blue, 0.75, 0.28, 0, 6.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(ID_SHOWINFORM, g_SyncHud,"[Level: Complete] ^n[EXP: Complete]")
}
else
{
set_hudmessage(level_red, level_green, level_blue, 0.01, 0.28, 0, 6.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(ID_SHOWINFORM, g_SyncHud,"[Level: %s] ^n[EXP: %d/ %d]",RANKS[iLevel[ID_SHOWINFORM]], iXP[ID_SHOWINFORM], EXP[iLevel[ID_SHOWINFORM] + 1])
}
}
if (get_pcvar_num(cvar_hud_position2))
{
if(iLevel[ID_SHOWINFORM] == 18)
{
set_hudmessage(level_red, level_green, level_blue, 0.75, 0.28, 0, 6.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(ID_SHOWINFORM, g_SyncHud,"[Level: Complete] ^n[EXP: Complete]")
}
else
{
set_hudmessage(level_red, level_green, level_blue, 0.75, 0.28, 0, 6.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(ID_SHOWINFORM, g_SyncHud,"[Level: %s] ^n[EXP: %d/ %d]",RANKS[iLevel[ID_SHOWINFORM]], iXP[ID_SHOWINFORM], EXP[iLevel[ID_SHOWINFORM] + 1])
}
}
}
}
public ShowScore(id)
{
new score_red, score_green, score_blue
score_red = get_pcvar_num(cvar_score_red)
score_green = get_pcvar_num(cvar_score_green)
score_blue = get_pcvar_num(cvar_score_blue)
set_hudmessage(score_red, score_green, score_blue, -1.0, 0.02, 0, 6.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(0, g_SyncHud, "[Zombie] - [Human]^n[%s%d] ----- [%s%d]",g_zombiescore >= 10 ? "" : "0", g_zombiescore, g_humanscore >= 10 ? "" : "0", g_humanscore )
}
public client_authorized(id)
{
// Just get the connecting users authid and store it in our global string array so it
// will not need to be retrieved every time we want to do an nvault transaction
if (get_pcvar_num(cvar_save_steam))
{
get_user_authid(id, iSteamID[id], charsmax(iSteamID))
}
if (get_pcvar_num(cvar_save_name))
{
get_user_name(id, iName[id], charsmax(iName))
}
}
public client_disconnect(id)
{
SaveData(id)
remove_task(id+TASK_SHOWINFORM)
iLevel[id] = 0
iXP[id] = 0
}
public custom_menu(id)
{
new menu = menu_create("\yLevel Menu \r2.4", "menu_handler")
menu_additem( menu, "\wShow top player!", "1", 0 );
menu_additem( menu, "\wEXP for next level", "2", 0 );
menu_additem( menu, "\wSave your EXP!", "3", 0 );
menu_display( id, menu, 0 );
}
public menu_handler( id, menu, item )
{
switch( item )
{
case 0: client_cmd(id, "say /cltop")
case 1: client_cmd(id, "say /clnext")
case 2: client_cmd(id, "say /savecl")
}
menu_destroy( menu );
}
#if defined CUSTOM_CHAT
public hook_say(id)
{
new szMessage[192], szName[32]
read_args(szMessage, charsmax(szMessage))
remove_quotes(szMessage)
get_user_name(id, szName, charsmax(szName))
if(equali(szMessage[0], " ") || equali(szMessage[0], "") || !is_valid_msg(szMessage))
return PLUGIN_HANDLED_MAIN
if(is_user_alive(id))
{
format(szMessage, charsmax(szMessage), "^4[%s] ^3%s : ^1%s", RANKS[iLevel[id]], szName, szMessage)
}
else
{
format(szMessage, charsmax(szMessage), "^1*DEAD* ^4[%s] ^3%s : ^1%s", RANKS[iLevel[id]], szName, szMessage)
}
new iPlayers[32]
new iPlayerCount, i, player
get_players(iPlayers, iPlayerCount, "ach")
for(i = 0; i < iPlayerCount; i++)
{
player = iPlayers[i]
message_begin(MSG_ONE, g_msgSayText, {0, 0, 0}, player)
write_byte(id)
write_string(szMessage)
message_end()
}
return PLUGIN_CONTINUE
}
public hook_say_team(id)
{
new szMessage[192], szName[32]
read_args(szMessage, charsmax(szMessage))
remove_quotes(szMessage)
get_user_name(id, szName, charsmax(szName))
if(equali(szMessage[0], " ") || equali(szMessage[0], "") || !is_valid_msg(szMessage))
return PLUGIN_HANDLED_MAIN
if(is_user_alive(id))
{
format(szMessage, charsmax(szMessage), "^4[%s] ^3%s : ^1%s", RANKS[iLevel[id]], szName, szMessage)
}
else
{
format(szMessage, charsmax(szMessage), "^1*DEAD* ^4[%s] ^3%s : ^1%s", RANKS[iLevel[id]], szName, szMessage)
}
new teamid = get_user_team(id)
new iPlayers[32]
new iPlayerCount, i, player
get_players(iPlayers, iPlayerCount, "ach")
for(i = 0; i < iPlayerCount; i++)
{
player = iPlayers[i]
new teami = get_user_team(player)
if(teamid == teami)
{
message_begin(MSG_ONE, g_msgSayText, {0, 0, 0}, player)
write_byte(id)
write_string(szMessage)
message_end()
}
}
return PLUGIN_CONTINUE
}
#endif
public cl_give(id, level, cid)
{
if (!cmd_access(id, level, cid, 2))
{
return PLUGIN_HANDLED
}
new iTarget[32]
new iCount[32]
read_argv(1, iTarget, charsmax(iTarget))
read_argv(2, iCount, charsmax(iCount))
new target_id, iName[32], iNameID[32]
target_id = find_player("bl", iTarget)
get_user_name(target_id, iName, charsmax(iName))
get_user_name(id, iNameID, charsmax(iNameID))
if(!target_id)
{
console_print(id, "Can't find that player")
return PLUGIN_HANDLED
}
if(read_argc() != 3)
return PLUGIN_HANDLED
if(str_to_num(iCount) < (EXP[iLevel[target_id] + 1] - iXP[target_id]))
{
if(str_to_num(iCount) == 0)
console_print(id, "EXP for %s is %i / %i", iName, iXP[target_id], EXP[iLevel[target_id] + 1])
else
{
console_print(id, "%s has been given %i EXP", iName, str_to_num(iCount))
iXP[target_id] += str_to_num(iCount)
}
}
else
{
console_print(id, "Maximum EXP allowed for %s: %i", iName, (EXP[iLevel[target_id] + 1] - iXP[target_id]))
}
return PLUGIN_HANDLED
}
public show_stats(id)
{
if(is_user_connected(id))
{
print_colored(id, "!t[CL]!g %L", id, "SHOW_STAT", RANKS[iLevel[id]], (EXP[iLevel[id] + 1] - iXP[id]))
}
}
public show_top(id)
{
show_motd( id, g_szTopMotd, "TOP LEVEL" )
}
public save_data(id)
{
if(is_user_alive(id))
{
SaveData(id)
print_colored(id, "!g[CL]!t %L", LANG_PLAYER, "SAVE")
}
}
public event_new_round()
{
new iPlayers[32]
new iPlayerCount, i, player
get_players(iPlayers, iPlayerCount, "ah")
for(i = 0; i < iPlayerCount; i++)
{
player = iPlayers[i]
iDamage[player][player] = 0
}
}
public event_Restart()
{
if (get_pcvar_num(cvar_e5))
{
g_zombiescore = 0
g_humanscore = 0
}
}
public event_damage(iVictim)
{
new iAttacker; iAttacker = get_user_attacker(iVictim)
if( iAttacker == iVictim || !is_user_alive(iAttacker) || !is_user_alive(iVictim))
return
if (get_pcvar_num(cvar_e3))
{
new iHit; iHit = read_data(2)
set_hudmessage(255, 0, 0, 0.45, 0.50, 2, 0.1, 4.0, 0.1, 0.1, -1)
ShowSyncHudMsg(iVictim, g_SyncHud, "%i^n", iHit)
}
if (get_pcvar_num(cvar_e4))
{
new iHit; iHit = read_data(2)
set_hudmessage(0, 100, 200, -1.0, 0.55, 2, 0.1, 4.0, 0.02, 0.02, -1)
ShowSyncHudMsg(iAttacker, g_SyncHud, "%i^n", iHit)
}
#if defined IM_USING_ZP50
if(zp_core_is_zombie(iVictim))
#else
if(zp_get_user_zombie(iVictim))
#endif
{
iDamage[iAttacker][iVictim] += read_data(2)
}
}
public event_deathMsg()
{
new iKiller; iKiller = read_data(1)
new iVictim; iVictim = read_data(2)
new iIsHeadshot; iIsHeadshot = read_data(3)
if(iVictim == iKiller || !is_user_alive(iKiller))
return
#if defined IM_USING_ZP50
if(!zp_core_is_zombie(iKiller))
#else
if(!zp_get_user_zombie(iKiller))
#endif
{
if(zp_get_user_nemesis(iVictim))
{
if (get_pcvar_num(cvar_e8))
{
iXP[iKiller] += cached_nemesis_xp
print_colored(iKiller, "!g[CL]!t %L", LANG_PLAYER, "KILL_NEMESIS", cached_nemesis_xp)
while((iXP[iKiller] >= EXP[iLevel[iKiller] + 1] && iLevel[iKiller] < 18))
{
iLevel[iKiller] += 1
print_colored(iKiller, "!g[CL]!t %L", LANG_PLAYER, "LEVEL_UP", RANKS[iLevel[iKiller]])
NextLevel(iKiller)
}
}
}
else
{
if(iIsHeadshot)
{
iKilledZombie[iKiller][iVictim] = true
iXP[iKiller] += cached_hsxp
print_colored(iKiller, "!g[CL]!t %L", LANG_PLAYER, "HEADSHOT_KILL", cached_hsxp)
}
else
{
iKilledZombie[iKiller][iVictim] = true
iXP[iKiller] += cached_xp
print_colored(iKiller, "!g[CL]!t %L", LANG_PLAYER, "KILL", cached_xp)
}
while((iXP[iKiller] >= EXP[iLevel[iKiller] + 1] && iLevel[iKiller] < 18))
{
iLevel[iKiller] += 1
print_colored(iKiller, "!g[CL]!t %L", LANG_PLAYER, "LEVEL_UP", RANKS[iLevel[iKiller]])
NextLevel(iKiller)
}
#if defined IM_USING_ZP50
new iPlayers[32]
new iPlayerCount, i, id
get_players(iPlayers, iPlayerCount, "ah")
for(i = 0; i < iPlayerCount; i++)
{
id = iPlayers[i]
if(iDamage[id][iVictim] >= iMaxHealth[iVictim] / cached_divide)
{
if(!iKilledZombie[id][iVictim])
{
if (zp_core_is_zombie(id))
return
iXP[id] += cached_assistxp
new szName[32]
get_user_name(iKiller, szName, charsmax(szName))
print_colored(id, "!g[CL]!t %L", LANG_PLAYER, "ASSIST", cached_assistxp, RANKS[iLevel[iKiller]], szName)
while((iXP[id] >= EXP[iLevel[id] + 1] && iLevel[id] < 18))
{
iLevel[id] += 1
print_colored(id, "!g[CL]!t %L", LANG_PLAYER, "LEVEL_UP", RANKS[iLevel[id]])
NextLevel(id)
}
iDamage[id][iVictim] = 0
}
else
{
iKilledZombie[id][iVictim] = false
}
}
}
#endif
}
}
else
{
if(zp_get_user_survivor(iVictim))
{
if (get_pcvar_num(cvar_e7))
{
iXP[iKiller] += cached_survivor_xp
print_colored(iKiller, "!g[CL]!t %L", LANG_PLAYER, "KILL_SURVIVOR", cached_survivor_xp)
while((iXP[iKiller] >= EXP[iLevel[iKiller] + 1] && iLevel[iKiller] < 18))
{
iLevel[iKiller] += 1
print_colored(iKiller, "!g[CL]!t %L", LANG_PLAYER, "LEVEL_UP", RANKS[iLevel[iKiller]])
NextLevel(iKiller)
}
}
}
else
{
iXP[iKiller] += cached_zxp
print_colored(iKiller, "!g[CL]!t %L", LANG_PLAYER, "KILL_HUMAN", cached_zxp)
while((iXP[iKiller] >= EXP[iLevel[iKiller] + 1] && iLevel[iKiller] < 18))
{
iLevel[iKiller] += 1
print_colored(iKiller, "!g[CL]!t %L", LANG_PLAYER, "LEVEL_UP", RANKS[iLevel[iKiller]])
NextLevel(iKiller)
}
}
}
}
public NextLevel(id)
{
if (get_pcvar_num(cvar_e1))
{
iXP[id] += cached_levelxp
print_colored(id, "!g[CL]!t %L", LANG_PLAYER, "BONUS_EXP", get_pcvar_num(cvar_level_bonus))
}
if (get_pcvar_num(cvar_e2))
{
zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + get_pcvar_num(cvar_apamount))
print_colored(id, "!g[CL]!t %L", LANG_PLAYER, "BONUS_AP", get_pcvar_num(cvar_apamount))
}
if (get_pcvar_num(cvar_bonus))
{
set_task(3.0, "iBonus", id)
}
}
public event_StatusValue(id)
{
if(!cached_icon)
return
new pid = read_data(2)
new pidlevel = iLevel[pid]
#if defined IM_USING_ZP50
if(!pev_valid(pid) || !is_user_alive(pid) || zp_core_is_zombie(pid))
return
#else
if(!pev_valid(pid) || !is_user_alive(pid) || zp_get_user_zombie(pid))
return
#endif
new flTime = floatround(cached_icon_time * 10)
if (flTime > 0)
Create_TE_PLAYERATTACHMENT(id, pid, 55, iSprite[pidlevel], flTime)
}
public fw_PlayerRespawn(id)
{
if (is_user_alive(id))
{
set_task(5.0, "iBonus", id)
set_task(4.0, "iInform", id)
set_task(25.0, "iSave", id)
}
}
public iSave(id)
{
if(is_user_alive(id))
{
print_colored(id, "!g[CL]!t %L", LANG_PLAYER, "INFORM_3")
}
}
public iBonus(id)
{
if (is_user_alive(id))
{
#if defined IM_USING_ZP50
if (zp_core_is_zombie(id))
return
#else
if (zp_get_user_zombie(id))
return
#endif
new iHealth, iArmor
iHealth = iLevel[id] * get_pcvar_num(cvar_health_bonus)
iArmor = iLevel[id] * get_pcvar_num(cvar_armor_bonus)
if (get_pcvar_num(cvar_bonus))
{
set_user_health(id, get_user_health(id) + iHealth)
set_user_armor(id, get_user_armor(id) + iArmor)
print_colored(id, "!g[CL]!t %L", LANG_PLAYER, "INFORM", RANKS[iLevel[id]], iHealth, iArmor)
}
}
}
public iInform(id)
{
if(is_user_alive(id))
{
print_colored(id, "!g[CL]!t %L", LANG_PLAYER, "INFORM_2")
}
}
#if defined CUSTOM_CHAT
public message_SayText(id)
{
return PLUGIN_HANDLED
}
#endif
#if defined IM_USING_ZP50
public zp_fw_core_infect_post(id, attacker)
{
if (zp_class_zombie_get_current(id) == ZP_INVALID_ZOMBIE_CLASS)
return;
iMaxHealth[id] = zp_class_zombie_get_max_health(id, zp_class_zombie_get_current(id))
}
#endif
#if defined CHANGE_NAME
public FwdClientUserInfoChanged( id, szBuffer )
{
if ( !is_user_connected( id ) )
return FMRES_IGNORED;
static szNewName[32];
engfunc( EngFunc_InfoKeyValue, szBuffer, "name", szNewName, charsmax(szNewName));
if(equal(szNewName, iName[id]))
return FMRES_IGNORED;
SaveData(id)
print_colored(id, "!g[CL]!t %L", LANG_PLAYER, "CHANGE_NAME2", iName[id], szNewName)
print_colored(id, "!g[CL]!t %L", LANG_PLAYER, "CHANGE_NAME3", szNewName)
copy( iName[id], charsmax(iName[]), szNewName );
LoadData(id)
print_colored(id, "!g[CL]!t %L", LANG_PLAYER, "CHANGE_NAME4")
return FMRES_IGNORED;
}
#endif
SaveData(id)
{
new szData[35]
new szKey[40]
if (get_pcvar_num(cvar_save_steam))
{
formatex(szKey, charsmax(szKey), "%s", iSteamID[id])
}
if (get_pcvar_num(cvar_save_name))
{
formatex(szKey, charsmax(szKey), "%s", iName[id])
}
formatex(szData, charsmax(szData), "%d %d", iLevel[id], iXP[id])
nvault_set(g_iVault, szKey, szData)
}
LoadData(id)
{
new szData[32]
new szKey[40]
if (get_pcvar_num(cvar_save_steam))
{
formatex(szKey, charsmax(szKey), "%s" , iSteamID[id])
}
if (get_pcvar_num(cvar_save_name))
{
formatex(szKey, charsmax(szKey), "%s", iName[id])
}
if(nvault_get(g_iVault, szKey, szData, charsmax(szData)))
{
new iSpacePos = contain(szData, " ")
if(iSpacePos > -1)
{
new szLevel[2]
new szXP[32]
parse(szData , szLevel, charsmax(szLevel), szXP, charsmax(szXP))
iLevel[id] = str_to_num(szLevel)
iXP[id] = str_to_num(szXP)
}
}
}
#if defined CUSTOM_CHAT
bool:is_valid_msg(const szMessage[])
{
if(szMessage[0] == '@' || szMessage[0] == '/' || szMessage[0] == '!' || !strlen(szMessage))
return false
return true
}
#endif
stock FormatTop(iNum)
{
// open the vault
new vault = nvault_util_open("custom_level");
// create our array to hold entries and keep track of its size
new Array:entries = ArrayCreate(VaultData);
new sizeEntries;
// count entries in vault and prepare variables
new numEntries = nvault_util_count(vault);
new data[VaultData], value[12], data2[VaultData];
// iterate through all entries
for(new i = 0, pos, timestamp; i < numEntries; i++)
{
// grab entry data from current position
pos = nvault_util_read(vault, pos, data[VD_Key], charsmax(data[VD_Key]), value, charsmax(value), timestamp);
// turn value string into integer
data[VD_Value] = str_to_num(value);
// if this is the first entry
if(sizeEntries == 0)
{
// go ahead and add it
ArrayPushArray(entries, data);
sizeEntries++;
}
else
{
// loop through other entries to see where this one should be placed (sorted from HIGH->LOW)
for(timestamp = 0; timestamp <= sizeEntries; timestamp++)
{
// if we looped through all entries without finding a place
if(timestamp == sizeEntries)
{
// this entry value is too low to fit before any others
// if we have room at the end of the array
if(sizeEntries < iNum)
{
// add it to the end
ArrayPushArray(entries, data);
sizeEntries++;
}
// don't continue with code below
break;
}
// grab current entry to compare it with
ArrayGetArray(entries, timestamp, data2);
// if this new entry should be placed before the compared entry
if(data[VD_Value] >= data2[VD_Value])
{
// insert before
ArrayInsertArrayBefore(entries, timestamp, data);
// if we aren't maxxed out
if(sizeEntries < iNum)
{
// increase entry size
sizeEntries++;
}
else
{
// delete the last entry to keep the size at maximum
ArrayDeleteItem(entries, sizeEntries);
}
break;
}
}
}
}
// close the vault
nvault_util_close(vault);
new iLen
new len = charsmax(g_szTopMotd)
iLen = formatex(g_szTopMotd, len, "<STYLE>body{background:#212121;color:#d1d1d1;font-family:Arial}table{width:100%%;font-size:19px}</STYLE><table cellpadding=1 cellspacing=1 border=0>")
iLen += formatex(g_szTopMotd[iLen], len - iLen, "<tr bgcolor=#333333><th width=1%%><align=left font color=white> %s <th width=5%%> %-22.22s <th width=5%%> %s", "#", "NAME", "LEVEL")
new i
for(i = 0; i < sizeEntries; i++)
{
ArrayGetArray(entries, i, data);
data[VD_Key][20] = 0;
replace_all(data[VD_Key], charsmax(data[VD_Key]), "<", "<")
replace_all(data[VD_Key], charsmax(data[VD_Key]), ">", ">")
iLen += formatex(g_szTopMotd[iLen], len - iLen, "<tr align=left%s><td align=left><font color=white> %d. <td> %-22.22s <td> %d", " bgcolor=#2b5b95", (i+1), data[VD_Key], data[VD_Value])
}
ArrayDestroy(entries);
iLen += formatex(g_szTopMotd[iLen], len - iLen, "</table></body>")
}
stock Create_TE_PLAYERATTACHMENT(id, entity, vOffset, iSprite, life)
{
message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
write_byte(TE_PLAYERATTACHMENT)
write_byte(entity)
write_coord(vOffset)
write_short(iSprite)
write_short(life)
message_end()
}
stock print_colored(const index, const input [ ], const any:...)
{
new message[191]
vformat(message, 190, input, 3)
replace_all(message, 190, "!y", "^1")
replace_all(message, 190, "!t", "^3")
replace_all(message, 190, "!g", "^4")
if(index)
{
//print to single person
message_begin(MSG_ONE, g_msgSayText, _, index)
write_byte(index)
write_string(message)
message_end()
}
else
{
//print to all players
new players[32], count, i, id
get_players(players, count, "ch")
for( i = 0; i < count; i ++ )
{
id = players[i]
if(!is_user_connected(id)) continue;
message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, id)
write_byte(id)
write_string(message)
message_end()
}
}
}
the problem is that reserves levels collected in such a way that if someone deletes cs and install cs again no have XP / level