#include <amxmodx>
#include <cstrike>
#include <fun>
#define PLUGIN "Save Frags & Deaths"
#define VERSION "0.1"
new Trie:g_tFrags, Trie:g_tDeaths;
new g_Disconnected[33];
public plugin_init()
{
register_plugin(PLUGIN, VERSION, "Mia2904");
g_tFrags = TrieCreate();
g_tDeaths = TrieCreate();
register_message(get_user_msgid("ScoreInfo"), "message_ScoreInfo");
}
public client_putinserver(iId)
{
new szAuth[35];
get_user_authid(iId, szAuth, charsmax(szAuth));
// szAuth desde posicion 6 para no guardar la parte STEAM_
if (TrieKeyExists(g_tFrags, szAuth[6]))
{
new iFrags, iDeaths;
TrieGetCell(g_tFrags, szAuth[6], iFrags);
TrieGetCell(g_tDeaths, szAuth[6], iDeaths);
set_user_frags(iId, iFrags);
cs_set_user_deaths(iId, iDeaths);
}
g_Disconnected[iId] = 0;
}
public client_disconnected(id)
{
g_Disconnected[id] = 1;
}
public message_ScoreInfo(iMsgId, iMsgDest, iMsgEnt)
{
new iId, iFrags, iDeaths;
iId = get_msg_arg_int(1);
if(g_Disconnected[iId])
return;
iFrags = get_msg_arg_int(2);
iDeaths = get_msg_arg_int(3);
new szAuth[35];
get_user_authid(iId, szAuth, charsmax(szAuth));
TrieSetCell(g_tFrags, szAuth[6], iFrags);
TrieSetCell(g_tDeaths, szAuth[6], iDeaths);
}