#include <amxmodx>
#include <fakemeta>
#include <nvault>
#define MAX_CLASSES 9 + 1
new const g_Commands[][] =
{
"spectate",
"buu",
"goku",
"gohan",
"krillin",
"frieza",
"piccolo",
"trunks",
"vegeta",
"cell",
"ramdompc"
};
new const g_Models[MAX_CLASSES][] =
{
"",
"fatbuu",
"goku",
"gohan",
"krillin",
"frieza",
"piccolo",
"trunks",
"vegeta",
"cell"
};
new const g_StartingPowerlevels[MAX_CLASSES] =
{
0,
1250000,
750000,
600000,
600000,
800000,
650000,
650000,
700000,
900000
};
new const Float:g_AscendMutlipliers[MAX_CLASSES] =
{
0.0,
1.5,
2.0,
2.0,
2.0,
1.5,
1.5,
2.0,
2.0,
1.5
};
new const g_Vault[] = "plsave";
new bool:g_FirstSpawn[33][MAX_CLASSES];
public plugin_init()
{
register_plugin("PL Save", "1.3", "hleV");
register_clcmd("fullupdate", "FullUpdate");
for (new Slot = 0; Slot < sizeof(g_Commands); Slot++)
register_clcmd(g_Commands[Slot], "ClassChange");
register_event("ResetHUD", "ResetHUD", "be");
}
public ClassChange(Client)
for (new Slot = 1; Slot < MAX_CLASSES; Slot++)
g_FirstSpawn[Client][Slot] = true;
public client_disconnect(Client)
SavePowerlevel(Client);
public FullUpdate()
return PLUGIN_HANDLED;
public ResetHUD(Client)
{
static Class;
Class = GetClass(Client);
if (!g_FirstSpawn[Client][Class])
return;
LoadPowerlevel(Client);
g_FirstSpawn[Client][Class] = false;
}
LoadPowerlevel(Client)
{
static Class;
Class = GetClass(Client);
if (!Class)
return;
static Vault;
Vault = nvault_open(g_Vault);
static Key[24];
get_user_authid(Client, Key, 21);
format(Key, 23, "%s %d", Key, Class);
static Value[10];
nvault_get(Vault, Key, Value, 9);
static Powerlevel;
Powerlevel = str_to_num(Value);
if (!Powerlevel)
Powerlevel = g_StartingPowerlevels[Class];
SetPowerlevel(Client, Powerlevel);
}
SavePowerlevel(Client)
{
static Class;
Class = GetClass(Client);
if (!Class)
return;
static Model[8];
GetModel(Client, Model, 7);
static Powerlevel;
Powerlevel = GetPowerlevel(Client);
if (!equal(Model, g_Models[Class]))
Powerlevel = floatround(Powerlevel / g_AscendMutlipliers[Class]);
static Key[24];
get_user_authid(Client, Key, 21);
format(Key, 23, "%s %d", Key, Class);
static Value[10];
num_to_str(Powerlevel, Value, 9);
static Vault;
Vault = nvault_open(g_Vault);
nvault_set(Vault, Key, Value);
nvault_close(Vault);
}
stock GetClass(Client)
return pev(Client, pev_playerclass);
stock GetModel(Client, Model[], Length)
get_pdata_string(Client, 1420, Model, Length, 0, 20);
stock GetPowerlevel(Client)
return get_pdata_int(Client, 460, 5);
stock SetPowerlevel(Client, Powerlevel)
{
set_pdata_int(Client, 460, Powerlevel, 5);
set_pdata_int(Client, 461, Powerlevel, 5);
}