Page 1 of 1

[CVars - Singleplayer] Constantly saved CVars?

Posted: Thu Dec 11, 2014 9:48 pm
by Vincent(PDP)
I have made a script that loops every tic, and besides some other coding in it, I have something that will calculate for how long you have played IN TOTAL (after closing and opening the game too). For this I use CVars, but is it a good idea to make it save all CVars each second in singleplayer? Or will it lag/eat up your RAM/CPU? (I do this because disconnect scripts only work in multiplayer).

Code: Select all

Script 513 ENTER CLIENTSIDE
{
Int Tics = 0;
Int SecondsTotal = 0;

    While(TRUE)
    {
        If(PlayerNumber() != ConsolePlayerNumber())
        {
            Terminate;
        }
        
        Tics ++;
        If(Tics >= 35)
        {
            Tics = 0;
            SecondsTotal ++;
            If(GameType() == GAME_SINGLE_PLAYER)
            {
                SaveAllStatsAndSettings();
            }
        }

    ... other code here ...

    Delay(1);
    }
}
Please note that there are other scripts that uses CVars too, and those scripts executes when you kill a monster etc...

RE: [CVars - Singleplayer] Constantly saved CVars?

Posted: Fri Dec 12, 2014 2:18 am
by Watermelon
Unless you're saving like 10,000 cvars every gametic, you should be fine.

If you're writing to the database, I'm unsure. I assume you should be able to do hundreds still per gametic fine.