Saving plugin data on shutdown

gintaras

Plugin Developer
Plugin Developer
Jan 10, 2017
68
138
8
Hi,
i need somehow to detect when server is shuting down to save plugin data to file
i tryed On_PluginShutdown but it not worked any suggestions?
 

gintaras

Plugin Developer
Plugin Developer
Jan 10, 2017
68
138
8
I have arrays
Code:
PluginDBWoodLVL = {}
PluginDBOreLVL = {}
PluginDBAnimalLVL = {}
PluginDBWoodEXP = {}
PluginDBOreEXP = {}
PluginDBAnimalEXP = {}
I saving this with timer now to file it stores player exp and level
i done this to reduce procesor usage but i need save when shuting down server
i have function:

Code:
    def SaveData(self):
        saving = Plugin.GetIni("Database")
        for key, value in PluginDBWoodLVL.iteritems():
            saving.AddSetting("LevelWood", str(key),str(value))
....
Everything works good only need somehow to save when i restarting server i made for my self cmd commend to save but it better make autosave :D
ohh and timer broked after ~100 cikles
so I made after 1k gather actions to save :D
 

gintaras

Plugin Developer
Plugin Developer
Jan 10, 2017
68
138
8
on plugin init
Plugin.CreateTimer("SaveData", 300000).Start()

def SaveDataCallback(self):
Plugin.CreateTimer("SaveData", 300000).Start()

Tryed not helped
Dretax maybe its better for me to use Datastore?
in file i save player ID and level or exp
Maybe there is better solution... to use datastore