Fix save action Problem Solved!
Hey guys, and merry christmas! I hope you are enjoying your holyday as much as I am!
Anyway, I've met some problems while trying to make (completely edit) a time plugin.
The plugin I'm editing is
this one.
The plugin is a time tracker, that keeps the time spent on the server of each and single player.
My problem is that when you play on the server and it changes map etc your time is saved and there seems to be no problem, but if you disconnect and then change nick and rejoin the server, your time is totally restarted.
This is of course because the saving method in the script seems to be saving by "nick" intead of "steamid".
However, if you look into the script, the plugin is saving intirely by steamid and not nick, but in the loading action is where things are getting messed up.
I don't know how to fix the loading action to be by steamid intirely so that it will work together with the saving action, so this is what I need help from you guys to fix.
Code:
public client_disconnect(id)
{
Save(id)
}
Code:
Save(id)
{
new szAuthId[35]; get_user_authid(id, szAuthId, charsmax(szAuthId))
new szTime[MAX_TIME_LENGTH]; num_to_str(g_iPlayedTime[id] + get_user_time(id), szTime, charsmax(szTime))
nvault_remove(gVault, szAuthId)
nvault_set(gVault, szAuthId, szTime)
// g_iPlayedTime[id] = 0
}
Code:
public client_putinserver(id)
{
g_iPlayedTime[id] = get_user_totaltime(id)
}
Code:
get_user_totaltime(id)
{
new iNum, szSavedName[32]
new szName[32]; get_user_name(id, szName, 31)
new szAuthId[33]; get_user_authid(id, szAuthId, charsmax(szAuthId))
if( !( iNum = nvault_get(gVault, szAuthId) ) )
{
nvault_set(gVault, szAuthId, "0")
format(szAuthId, charsmax(szAuthId), "%s%s", szAuthId, SPECIAL_CHAR)
nvault_set(gVault, szAuthId, szName)
return 0
}
format(szAuthId, charsmax(szAuthId), "%s%s", szAuthId, SPECIAL_CHAR)
nvault_get(gVault, szAuthId, szSavedName)
if(!equal(szName, szSavedName))
{
nvault_remove(gVault, szAuthId)
nvault_set(gVault, szAuthId, szTime)
}
nvault_remove(gVault, szAuthId)
nvault_set(gVault, szAuthId, szTime)
return iNum
}
Removed .sma file - Problem solved