PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <fakemeta>
#define AUTHOR "Chris"
#define VERSION "1.0"
#define PLUGIN "Permanent Kills/Deaths"
new const SAVE_FILE[] = "KillsDeaths";
new Vault;
public plugin_init()
{
register_plugin("Permanent Kills/Deaths", VERSION, "Chris");
}
public client_putinserver(id)
{
LoadData(id);
return PLUGIN_HANDLED;
}
public client_disconnect(id)
{
SaveData(id);
return PLUGIN_HANDLED;
}
GetSaveKey(id, Key[])
{
static AuthId[32];
get_user_authid(id,AuthId,32);
format(Key, 63,"%s",AuthId);
}
public plugin_end()
{
new iPlayers[32],iNum;
for(new i=0;i<iNum;i++)
{
SaveData(iPlayers[i]);
}
return PLUGIN_HANDLED;
}
SaveData(id)
{
Vault = nvault_open(SAVE_FILE);
if(Vault == INVALID_HANDLE)
{
log_amx("Error opening nVault file: %s", SAVE_FILE);
return PLUGIN_HANDLED;
}
static Key[64], Data[30];
new sKills[15],sDeaths[15];
new TimeStamp;
if(nvault_lookup(Vault, Key, Data, 29, TimeStamp))
{
parse(Data,sKills,14,sDeaths,14);
}
new Kills = str_to_num(sKills)
new Deaths = str_to_num(sDeaths)
Kills += pev(id, pev_frags); //problem
Deaths += get_user_deaths(id); //problem
GetSaveKey(id,Key);
format(Data, 29,"%i %i", Kills, Deaths);
nvault_set(Vault, Key, Data);
nvault_close(Vault);
return PLUGIN_HANDLED;
}
LoadData(id)
{
Vault = nvault_open(SAVE_FILE);
if(Vault == INVALID_HANDLE)
{
log_amx("Error opening nVault file: %s", SAVE_FILE);
return PLUGIN_HANDLED;
}
static Key[64], Data[30];
new TimeStamp;
GetSaveKey(id,Key);
if(nvault_lookup(Vault, Key, Data, 29, TimeStamp))
{
new sKills[15],sDeaths[15];
parse(Data,sKills,14,sDeaths,14);
set_pev(id, pev_frags, str_to_float(sKills));
set_pdata_int(id, 290, str_to_num(sDeaths));
}
nvault_close(Vault);
return PLUGIN_HANDLED;
}