PHP Code:
Save(id)
{
new szAuthId[32];
get_user_authid(id, szAuthId, charsmax(szAuthId));
new szName[32];
get_user_name(id, szName, charsmax(szName));
new szData[200];
formatex(szData, charsmax(szData), "^"%s^" ^"%i^"", szName, g_iPoints[id]);
nvault_set(g_iVault, szAuthId, szData);
}
Load(id)
{
new szAuthId[32]; get_user_authid(id, szAuthId, charsmax(szAuthId));
new szData[200], iTimeStamp;
if(nvault_lookup(g_iVault, szAuthId, szData, charsmax(szData), iTimeStamp))
{
new szSavedname[32], szPoint[16];
parse(szData, szSavedname, charsmax(szSavedname), szPoint, charsmax(szPoint))
remove_quotes(szSavedname)
remove_quotes(szPoint)
set_user_info(id, "name", szSavedname)
g_iPoints[id] = str_to_num(szPoint)
}
}
PHP Code:
public plugin_init()
{
register_plugin( PLUGIN, VERSION, AUTHOR )
new g_iVault = nvault_open("System");
if ( g_iVault == INVALID_HANDLE )
set_fail_state( "Error opening nVault" );
set_task(180.0, "Task_Advertise", _, _, _, "b");
}
public plugin_end()
{
nvault_close(g_iVault);
}
public client_putinserver(id)
{
if(is_user_hltv(id) || is_user_bot(id))
return PLUGIN_HANDLED;
Load(id);
return PLUGIN_HANDLED;
}
public client_disconnect(id)
{
if(is_user_hltv(id) || is_user_bot(id))
return PLUGIN_HANDLED;
Save(id);
return PLUGIN_HANDLED;
}
Is there any issue with the code?
Because on map change its causing the server to crash .. And when we delete the vault file from data-> vault then only the server is able to start