feat(esx_property): Lots of Server-Sided Exports

adds:
- GetProperties
- GetOwnedProperties
- GetNonOwnedProperties
- GetPlayerProperties(identifier)
- GetPropertyKeys(PropertyId)
- DoesPlayerHaveKeys(PropertyId, Identifier)
- ForceSaveProperties -- Tells u which resource executed it aswell
This commit is contained in:
Mycroft
2022-09-10 19:29:42 +01:00
parent 91c22ce1fb
commit 49fa16fb9d
2 changed files with 58 additions and 0 deletions
+1
View File
@@ -200,5 +200,6 @@ Locales['en'] = {
["server_shutdown"] = "Server Shutdown",
["manual_save"] = "Manual Save (Requested By %s)",
["resource_stop"] = "Resource Stopping",
["force_save"] = "Force Save (Requested By %s)",
["interval_saving"] = "Interval Saving"
}
+57
View File
@@ -1121,3 +1121,60 @@ end)
ESX.RegisterCommand(_("save_name"), Config.AllowedGroups, function(xPlayer)
PropertySave(_U("manual_save", GetPlayerName(xPlayer.source)))
end, false,{help = _U("save_desc")})
----- Exports -----
exports("GetProperties", function()
return Properties
end)
exports("GetOwnedProperties", function()
local OwnedProperties = {}
for i=1, #Properties do
if Properties[i].Owned then
OwnedProperties[#OwnedProperties + 1] = Properties[i]
end
end
return OwnedProperties
end)
exports("GetNonOwnedProperties", function()
local NonOwnedProperties = {}
for i=1, #Properties do
if not Properties[i].Owned then
NonOwnedProperties[#NonOwnedProperties + 1] = Properties[i]
end
end
return NonOwnedProperties
end)
exports("GetPlayerProperties", function(identifier)
local PlayerProperties = {}
for i=1, #Properties do
if Properties[i].Owned and Properties[i].owner == identifier then
PlayerProperties[#PlayerProperties + 1] = Properties[i]
end
end
return PlayerProperties
end)
exports("GetPropertyKeys", function(PropertyId)
local Property = Properties[PropertyId]
if Property.Keys then
return Property.Keys
end
return {}
end)
exports("DoesPlayerHaveKeys", function(PropertyId, Identifier)
local Property = Properties[PropertyId]
if Property.Keys then
return Property.Keys[Identifier] and true or false
end
return {}
end)
exports("ForceSaveProperties", function()
local ExecutingResource = GetInvokingResource()
PropertySave(_U("forced_save", ExecutingResource))
end)