[CVars - Singleplayer] Constantly saved CVars?

Discuss all aspects related to modding Zandronum here.
Post Reply
User avatar
Vincent(PDP)
Forum Regular
Posts: 527
Joined: Thu Mar 14, 2013 7:35 pm
Location: Sweden
Clan: My DOOM site
Clan Tag: <MDS>
Contact:

[CVars - Singleplayer] Constantly saved CVars?

#1

Post by Vincent(PDP) » Thu Dec 11, 2014 9:48 pm

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...
//Visual Vincent ( Vincent (PDP) )
- My DOOM site Team

My projects:
Spoiler: (Open)
Doom Writer
Escape From The Laboratory - Done
Escape From The Laboratory Part 2
Parkskolan Zombie Horde Map (ZM10) - Done
In game Admin Commands for Zandronum.
Achievement Mod for Zandronum
Stats mod

Watermelon
Zandrone
Posts: 1244
Joined: Thu Jun 28, 2012 9:07 pm
Location: Rwanda

RE: [CVars - Singleplayer] Constantly saved CVars?

#2

Post by Watermelon » Fri Dec 12, 2014 2:18 am

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.

Post Reply