feat(esx_property): Save Properties on an interval

This commit is contained in:
Mycroft
2022-09-08 20:31:13 +01:00
parent 234d079820
commit b6b1175dda
2 changed files with 13 additions and 0 deletions
+1
View File
@@ -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
+12
View File
@@ -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)