From b6b1175dda1fb5cf75e668c9fd1e90f39637c00c Mon Sep 17 00:00:00 2001 From: Mycroft Date: Thu, 8 Sep 2022 20:31:13 +0100 Subject: [PATCH] feat(esx_property): Save Properties on an interval --- [esx_addons]/esx_property/config.lua | 1 + [esx_addons]/esx_property/server/main.lua | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/[esx_addons]/esx_property/config.lua b/[esx_addons]/esx_property/config.lua index 13fd373c..9cbe598d 100644 --- a/[esx_addons]/esx_property/config.lua +++ b/[esx_addons]/esx_property/config.lua @@ -8,6 +8,7 @@ Config.OwnedBlips = true -- Add blips for Owned Properties --------------------- General Settings --------------------------------- Config.Locale = 'en' Config.Shells = false -- Enable/Disable Shell Interiors Default: false +Config.SaveInterval = 5 -- Interval in Minutes to Save Properties Config.CanAlwaysExit = true -- Disabling this allows players to be locked in Config.OwnerCanAlwaysEnter = true -- Disabling this means the owner can't enter the property unless door is unlocked Config.MaxNameLength = 20 -- Max Name Length for Owned Properties Default: 20 diff --git a/[esx_addons]/esx_property/server/main.lua b/[esx_addons]/esx_property/server/main.lua index 0b7397fb..ea4bd250 100644 --- a/[esx_addons]/esx_property/server/main.lua +++ b/[esx_addons]/esx_property/server/main.lua @@ -1109,3 +1109,15 @@ AddEventHandler('onResourceStop', function(ResourceName) end end) +-- Save Properties every x Minutes + +CreateThread(function() + while true do + Wait(60000 * Config.SaveInterval) + if Properties and #Properties > 0 then + SaveResourceFile(GetCurrentResourceName(), 'properties.json', json.encode(Properties)) + Log("Properties Saving", 11141375, {{name = "**Reason**", value = "Interval Saving", inline = true}, + {name = "**Property Count**", value = tostring(#Properties), inline = true}}, 1) + end + end +end) \ No newline at end of file