How to compile this ?
PHP Code:
#include <amxmodx> #include <zombieplague> #include <adv_vault>
//#define ZP_42
new CAMPO_KILLS, CAMPO_POINTS
enum { KILL_ZOMBIE, KILL_NEMESIS, #if !defined ZP_42 KILL_ASSASSIN, KILL_SNIPER, #endif KILL_INFECT, KILL_HUMAN, KILL_SURVIVOR, MAX_KILLS }
new const points_per_kill[MAX_KILLS] = { 1, // Zombie 4, // Nemesis #if !defined ZP_42 4, // Assassin 6, // Sniper #endif 1, // Infect 2, // Human 5, // Survivor }
new g_kills[33][MAX_KILLS] new g_points[33] new g_name[33][32]
// HLSDK: #define MAX_MOTD_LENGTH 1536 new motd[1536] new g_vault, g_sort, g_maxplayers, g_msgSayText, cvar_reset
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_clcmd("say /rank", "clcmd_rank") register_clcmd("say /top15", "clcmd_oldtop") register_clcmd("say /top10", "clcmd_top") cvar_reset = register_cvar("zp_stats_reset", "0") register_event("DeathMsg", "event_death", "a") register_event("HLTV" , "round_start" , "a", "1=0", "2=0") g_msgSayText = get_user_msgid("SayText") g_maxplayers = get_maxplayers() g_vault = adv_vault_open("zp_stats", false) CAMPO_POINTS = adv_vault_register_field(g_vault, "points") CAMPO_KILLS = adv_vault_register_field(g_vault, "kills", DATATYPE_ARRAY, MAX_KILLS) adv_vault_init(g_vault) g_sort = adv_vault_sort_create(g_vault, ORDER_DESC, 0, 2000, CAMPO_POINTS) }
public client_infochanged(id) { if(!is_user_connected(id)) return
static newname[32] get_user_info(id, "name", newname, 31)
if(!equal(newname, g_name[id])) { copy(g_name[id], 31, newname) load_data(id) } }
public client_putinserver(id) { get_user_name(id, g_name[id], 31) load_data(id) }
public client_disconnect(id) { save_data(id) }
public fw_adv_vault_closed(vault) { if(vault == g_vault) { if(get_pcvar_num(cvar_reset)) { adv_vault_clear(g_vault, CLEAR_ALL) set_pcvar_num(cvar_reset, 0) } else round_start(true) } }
public round_start(skip) { for(new id=1; id <= g_maxplayers; id++) { if(is_user_connected(id)) save_data(id) } if(!skip) { adv_vault_sort_update(g_vault, g_sort) update_motd() } }
public event_death() { static attacker, victim attacker = read_data(1) victim = read_data(2) if(attacker == victim || !is_user_connected(attacker) || !is_user_connected(victim)) return static class class = get_class(victim) g_kills[attacker][class]++ g_points[attacker] += points_per_kill[class] }
public zp_user_infected_post(victim, infector) { if(infector) g_kills[infector][KILL_INFECT] += points_per_kill[KILL_INFECT] }
get_class(victim) { if(zp_get_user_zombie(victim)) { if(zp_get_user_nemesis(victim)) return KILL_NEMESIS #if !defined ZP_42 else if(zp_get_user_assassin(victim)) return KILL_ASSASSIN #endif return KILL_ZOMBIE } else if(zp_get_user_survivor(victim)) return KILL_SURVIVOR #if !defined ZP_42 else if(zp_get_user_sniper(victim)) return KILL_SNIPER #endif return KILL_HUMAN }
save_data(id) { adv_vault_set_start(g_vault) adv_vault_set_field(g_vault, CAMPO_POINTS, g_points[id]) adv_vault_set_field(g_vault, CAMPO_KILLS, g_kills[id]) adv_vault_set_end(g_vault, 0, g_name[id]) }
load_data(id) { if(!adv_vault_get_prepare(g_vault, _, g_name[id])) { arrayset(g_kills[id], 0, MAX_KILLS) g_points[id] = 0 return }
g_points[id] = adv_vault_get_field(g_vault, CAMPO_POINTS) adv_vault_get_field(g_vault, CAMPO_KILLS, g_kills[id], MAX_KILLS) }
public clcmd_rank(id) { new rank_position = adv_vault_sort_key(g_vault, g_sort, 0, g_name[id]) if(!rank_position) chat_color(id, "!g-!tYou're not ranked") else chat_color(id, "!g-!tYou ranking is !y%d !tof !y%d !twith !y%d !tpoints", rank_position, adv_vault_sort_numresult(g_vault, g_sort), g_points[id]) }
public clcmd_oldtop(id) { client_cmd(id, "say /top10") return PLUGIN_HANDLED }
public clcmd_top(id) { show_motd(id, motd, "ZP TOP-10") }
update_motd() { new kills[MAX_KILLS], points, keyindex, nick[96], len
motd[0] = 0 add(motd, charsmax(motd), "<html><style>\ body{background:#040404;font-family:Verdana, Arial, Sans-Serif;font-size:7pt;}\ .t{color:#808080;text-align:left; }\ #h{background: #222; font-weight:bold;}\ #p{color:#D41313;}\ #n{color:#fff;}\ </style><body>\ <table cellspacing=0 width=100% class=t>")
add(motd, charsmax(motd), "<tr><td id=h width=7%>#</td>\ <td id=h>Nick</td>\ <td id=h>Points</td>\ <td id=h>Zombie</td>\ <td id=h>Humans</td>\ <td id=h>Infect</td></tr>") len = strlen(motd)
new toploop = min(adv_vault_sort_numresult(g_vault, g_sort), 10)
for(new position=1; position <= toploop; position++) { keyindex = adv_vault_sort_position(g_vault, g_sort, position)
if(!adv_vault_get_prepare(g_vault, keyindex)) continue points = adv_vault_get_field(g_vault, CAMPO_POINTS) adv_vault_get_field(g_vault, CAMPO_KILLS, kills, MAX_KILLS) adv_vault_get_keyname(g_vault, keyindex, nick, charsmax(nick))
replace_all(nick, charsmax(nick), "<", "<") replace_all(nick, charsmax(nick), ">", ">") len += formatex(motd[len], charsmax(motd)-len, "<tr><td id=p>#%d</td>\ <td id=n>%s</td>\ <td>%d</td>\ <td>%d</td>\ <td>%d</td>\ <td>%d</td>", position, nick, points, kills[KILL_ZOMBIE], kills[KILL_HUMAN], kills[KILL_INFECT]) }
add(motd, charsmax(motd), "</table></body></html>") }
stock chat_color(const id, const input[], any:...) { new count = 1, players[32], i static msg[191]
if(numargs() == 2) copy(msg, 190, input) else 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) { if(!is_user_connected(id)) return players[0] = id } else get_players(players, count, "ch")
for(i = 0; i < count; i++) { message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, players[i]) write_byte(players[i]) write_string(msg) message_end() } }
error line adv_vault_open
|