Raised This Month: $32 Target: $400
 8% 

[CSGO]SQL Database Save Question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
johnny01
Junior Member
Join Date: Jun 2013
Old 04-30-2014 , 22:01   [CSGO]SQL Database Save Question
Reply With Quote #1

If I were to use the code below to save clients information, would it save incorrectly when new clients connect and previous clients leave?

PHP Code:
public OnMapStart()
{
    
CreateTimer(20.0Savior_TIMER_REPEAT);
}

public 
Action:Savior(Handle:timer)
{
    for (new 
client 1client <= MaxClientsclient++)
    {
        if (
IsClientInGame(client) && !IsFakeClient(client))
        {
            
DatabaseSave(client);
        }
    }


Last edited by johnny01; 04-30-2014 at 22:14.
johnny01 is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 05-02-2014 , 00:51   Re: [CSGO]SQL Database Save Question
Reply With Quote #2

Judge from your code, it will. Keep in mind that the save only firing every 20 seconds which is, if client leave before the interval, he leave without trace.

If I were you, I do that on client connected and disconnected.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.
GsiX is offline
Doodil
Senior Member
Join Date: Mar 2012
Old 05-02-2014 , 08:28   Re: [CSGO]SQL Database Save Question
Reply With Quote #3

It actually depends on the DatabaseSave() function. If the function retrieves the steam-id from the client-id and you clean up properly on disconnect/connect you should not have any problems. You do however not save the progress that happened since the last save this way.

But I agree with GsiX, you should load data on connect and save on disconnect, this way you won't unnecessarily spam your database every 20 seconds
Doodil is offline
floube
SourceMod Donor
Join Date: Jan 2013
Location: Austria
Old 05-09-2014 , 03:38   Re: [CSGO]SQL Database Save Question
Reply With Quote #4

Maybe use OnClientAuthorized (where you have the SteamID already)?
__________________
floube is offline
Reply


Thread Tools
Display Modes

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 20:21.


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