Raised This Month: $ Target: $400
 0% 

Fix Saving Action [SOLVED]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
andrzN
Senior Member
Join Date: Jan 2010
Location: Bodø / Norway
Old 12-24-2012 , 21:58   Fix Saving Action [SOLVED]
Reply With Quote #1

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

Last edited by andrzN; 12-25-2012 at 00:15.
andrzN is offline
Send a message via MSN to andrzN
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:16.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode