#include <amxmodx>
#include <reapi>
enum _:DATA { Float:KILLS, DEATH};
new g_szTempData[MAX_CLIENTS + 1][DATA];
new g_szAuthID[MAX_CLIENTS + 1][32];
new Trie:g_tPlayerScore;
public plugin_end() {
TrieDestroy(g_tPlayerScore);
}
public plugin_init() {
register_plugin("Save score", "1.0.0", "Minni Mouse");
g_tPlayerScore = TrieCreate();
}
public client_disconnected(pPlayer) {
if(is_user_hltv(pPlayer) || is_user_bot(pPlayer)) {
return;
}
if(g_szAuthID[pPlayer][0]) {
g_szTempData[pPlayer][KILLS] = Float:get_entvar(pPlayer, var_frags);
g_szTempData[pPlayer][DEATH] = get_member(pPlayer, m_iDeaths);
TrieSetArray(g_tPlayerScore, g_szAuthID[pPlayer], g_szTempData[pPlayer], DATA);
}
}
public client_putinserver(pPlayer) {
if(is_user_hltv(pPlayer) || is_user_bot(pPlayer)) {
return;
}
get_user_authid(pPlayer, g_szAuthID[pPlayer], charsmax(g_szAuthID[]));
if(TrieGetArray(g_tPlayerScore, g_szAuthID[pPlayer], g_szTempData[pPlayer], DATA)) {
set_entvar(pPlayer, var_frags, g_szTempData[pPlayer][KILLS]);
set_member(pPlayer, m_iDeaths, g_szTempData[pPlayer][DEATH]);
}
else {
arrayset(_:g_szTempData[pPlayer], _:0.0, sizeof(g_szTempData[]));
}
}