mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 09:18:53 +00:00
Merge branch 'esx-framework:main' into main
This commit is contained in:
@@ -109,7 +109,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
function self.getAccount(account)
|
||||
for i=1, #self.accounts do
|
||||
if self.accounts[i].name == account then
|
||||
return self.accounts[i], i
|
||||
return self.accounts[i]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -177,11 +177,11 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
return
|
||||
end
|
||||
if money >= 0 then
|
||||
local account, index = self.getAccount(accountName)
|
||||
local account = self.getAccount(accountName)
|
||||
|
||||
if account then
|
||||
money = account.round and ESX.Math.Round(money) or money
|
||||
self.accounts[index].money = money
|
||||
self.accounts[account.index].money = money
|
||||
|
||||
self.triggerEvent('esx:setAccountMoney', account)
|
||||
else
|
||||
@@ -198,10 +198,10 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
return
|
||||
end
|
||||
if money > 0 then
|
||||
local account, index = self.getAccount(accountName)
|
||||
local account = self.getAccount(accountName)
|
||||
if account then
|
||||
money = account.round and ESX.Math.Round(money) or money
|
||||
self.accounts[index].money += money
|
||||
self.accounts[account.index].money += money
|
||||
|
||||
self.triggerEvent('esx:setAccountMoney', account)
|
||||
else
|
||||
@@ -218,11 +218,11 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
return
|
||||
end
|
||||
if money > 0 then
|
||||
local account, index = self.getAccount(accountName)
|
||||
local account = self.getAccount(accountName)
|
||||
|
||||
if account then
|
||||
money = account.round and ESX.Math.Round(money) or money
|
||||
self.accounts[index].money -= money
|
||||
self.accounts[account.index].money -= money
|
||||
|
||||
self.triggerEvent('esx:setAccountMoney', account)
|
||||
else
|
||||
|
||||
@@ -131,8 +131,14 @@ function loadESXPlayer(identifier, playerId, isNew)
|
||||
if data.round == nil then
|
||||
data.round = true
|
||||
end
|
||||
userData.accounts[#userData.accounts + 1] = {name = account, money = foundAccounts[account] or Config.StartingAccountMoney[account] or 0,
|
||||
label = data.label, round = data.round}
|
||||
local index = #userData.accounts + 1
|
||||
userData.accounts[index] = {
|
||||
name = account,
|
||||
money = foundAccounts[account] or Config.StartingAccountMoney[account] or 0,
|
||||
label = data.label,
|
||||
round = data.round,
|
||||
index = index
|
||||
}
|
||||
end
|
||||
|
||||
-- Job
|
||||
|
||||
@@ -12,11 +12,7 @@ CreateThread(function()
|
||||
name = name,
|
||||
data = data
|
||||
})
|
||||
|
||||
ESX.SetTimeout(200, function()
|
||||
SetNuiFocus(true, true)
|
||||
end)
|
||||
|
||||
SetNuiFocus(true, true)
|
||||
end
|
||||
|
||||
local function closeMenu(namespace, name)
|
||||
@@ -46,11 +42,9 @@ CreateThread(function()
|
||||
|
||||
RegisterNUICallback('menu_submit', function(data, cb)
|
||||
local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name)
|
||||
|
||||
if menu.submit ~= nil then
|
||||
if menu.submit then
|
||||
menu.submit(data, menu)
|
||||
end
|
||||
|
||||
cb('OK')
|
||||
end)
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@
|
||||
let menu = $(Mustache.render(MenuTpl, view));
|
||||
|
||||
menu.find('button[data-namespace][data-name]').click(function() {
|
||||
ESX_MENU.data[$(this).data('namespace')][$(this).data('name')][parseInt($(this).data('id'))].currentRow = parseInt($(this).data('id')) + 1;
|
||||
ESX_MENU.submit($(this).data('namespace'), $(this).data('name'), {
|
||||
data : ESX_MENU.data[$(this).data('namespace')][$(this).data('name')][parseInt($(this).data('id'))],
|
||||
value: $(this).data('value')
|
||||
|
||||
@@ -361,7 +361,7 @@ CreateThread(function()
|
||||
ESX.ShowHelpNotification(v.Hint)
|
||||
hintIsShowed = true
|
||||
if IsControlJustReleased(0, 38) then
|
||||
ESX.Game.Teleport(PlayerPedId(), position)
|
||||
ESX.Game.Teleport(PlayerPedId(), v.Teleport)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -100,6 +100,7 @@ Locales['nl'] = {
|
||||
['box'] = 'Box',
|
||||
['fence'] = 'PD Hek',
|
||||
['cash'] = 'Pallet met geld',
|
||||
['spikestrips'] = 'Spijkermatten',
|
||||
-- ID Menu
|
||||
['name'] = 'Naam: %s',
|
||||
['job'] = 'Werk: %s',
|
||||
|
||||
@@ -877,7 +877,7 @@ function OpenPMQuickMenu(Action)
|
||||
end
|
||||
|
||||
ESX.RegisterInput(_U("realestate_command"), _U("realestate_command_desc"), "keyboard", "F5", function()
|
||||
ESX.TriggerServerCallback('esx_property:IsAdmin', function(Access)
|
||||
ESX.TriggerServerCallback('esx_property:CanAccessRealEstateMenu', function(Access)
|
||||
if Access then
|
||||
OpenPMQuickMenu("ActionsMenu")
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -194,4 +194,11 @@ Locales['en'] = {
|
||||
["cctv_textui_3"] = "Press ~b~[E]~s~ to Set Max Left Roation",
|
||||
["create_success"] = "Property created!",
|
||||
["missing_data"] = "Please Fill Out all Required Inputs!",
|
||||
|
||||
-- Saving Translations
|
||||
["server_restart"] = "Server Restarting",
|
||||
["server_shutdown"] = "Server Shutdown",
|
||||
["manual_save"] = "Manual Save (Requested By %s)",
|
||||
["resource_stop"] = "Resource Stopping",
|
||||
["interval_saving"] = "Interval Saving"
|
||||
}
|
||||
|
||||
@@ -165,12 +165,6 @@ ESX.RegisterCommand(_("refresh_name"), Config.AllowedGroups, function(xPlayer)
|
||||
PropertiesRefresh()
|
||||
end, false, {help = _U("refresh_desc")})
|
||||
|
||||
ESX.RegisterCommand(_("save_name"), Config.AllowedGroups, function(xPlayer)
|
||||
SaveResourceFile(GetCurrentResourceName(), 'properties.json', json.encode(Properties))
|
||||
Log("Properties Saving", 11141375,
|
||||
{{name = "**Reason**", value = "Requsted By Admin", inline = true}, {name = "**Property Count**", value = tostring(#Properties), inline = true}}, 1)
|
||||
end, false,{help = _U("save_desc")})
|
||||
|
||||
ESX.RegisterCommand(_("create_name"), "user", function(xPlayer)
|
||||
if IsPlayerAdmin(xPlayer.source) or (PM.Enabled and xPlayer.job.name == PM.job) then
|
||||
xPlayer.triggerEvent("esx_property:CreateProperty")
|
||||
@@ -1031,7 +1025,7 @@ AddEventHandler('playerDropped', function()
|
||||
end
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_property:CanCreateProperty', function(source, cb, num)
|
||||
ESX.RegisterServerCallback('esx_property:CanCreateProperty', function(source, cb)
|
||||
local Re = false
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
@@ -1044,10 +1038,16 @@ ESX.RegisterServerCallback('esx_property:CanCreateProperty', function(source, cb
|
||||
cb(Re)
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_property:IsAdmin', function(source, cb, num)
|
||||
ESX.RegisterServerCallback('esx_property:IsAdmin', function(source, cb)
|
||||
cb(IsPlayerAdmin(source, "ViewProperties"))
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_property:CanAccessRealEstateMenu', function(source, cb)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local Re = (Config.PlayerManagement.Enabled and xPlayer.job.name == Config.PlayerManagement.job and xPlayer.job.grade >= Config.PlayerManagement.Permissions.ManagePropertiesFromQuickActions) and true or false
|
||||
cb(Re)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx_property:server:createProperty', function(Property)
|
||||
local source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
@@ -1088,24 +1088,36 @@ AddEventHandler('txAdmin:events:scheduledRestart', function(eventData)
|
||||
end
|
||||
end)
|
||||
|
||||
--- Save Properties On Server Stop/Restart
|
||||
AddEventHandler('txAdmin:events:serverShuttingDown', function()
|
||||
function PropertySave(Reason)
|
||||
if Properties and #Properties > 0 then
|
||||
SaveResourceFile(GetCurrentResourceName(), 'properties.json', json.encode(Properties))
|
||||
Log("Properties Saving", 11141375,
|
||||
{{name = "**Reason**", value = "Server Shutdown", inline = true}, {name = "**Property Count**", value = tostring(#Properties), inline = true}}, 1)
|
||||
{{name = "**Reason**", value = Reason, inline = true}, {name = "**Property Count**", value = tostring(#Properties), inline = true}}, 1)
|
||||
end
|
||||
end
|
||||
|
||||
--- Save Properties On Server Stop/Restart
|
||||
AddEventHandler('txAdmin:events:serverShuttingDown', function()
|
||||
PropertySave(_U("server_shutdown"))
|
||||
end)
|
||||
|
||||
--- Save Properties On Resource Stop/Restart
|
||||
|
||||
AddEventHandler('onResourceStop', function(ResourceName)
|
||||
if ResourceName == GetCurrentResourceName() then
|
||||
if Properties and #Properties > 0 then
|
||||
SaveResourceFile(GetCurrentResourceName(), 'properties.json', json.encode(Properties))
|
||||
Log("Properties Saving", 11141375, {{name = "**Reason**", value = "Resource Restart", inline = true},
|
||||
{name = "**Property Count**", value = tostring(#Properties), inline = true}}, 1)
|
||||
end
|
||||
PropertySave(_U("resource_stop"))
|
||||
end
|
||||
end)
|
||||
|
||||
-- Save Properties every x Minutes
|
||||
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(60000 * Config.SaveInterval)
|
||||
PropertySave(_U("interval_save"))
|
||||
end
|
||||
end)
|
||||
|
||||
ESX.RegisterCommand(_("save_name"), Config.AllowedGroups, function(xPlayer)
|
||||
PropertySave(_U("manual_save", GetPlayerName(xPlayer.source)))
|
||||
end, false,{help = _U("save_desc")})
|
||||
|
||||
+2
-2
@@ -24,8 +24,8 @@ sv_licenseKey ""
|
||||
sv_maxclients 10 # Allow access to features usually locked behind a FiveM patreon key
|
||||
|
||||
sets sv_projectName "ESX Legacy"
|
||||
sets sv_projectDesc ""
|
||||
sets locale "en-GB"
|
||||
sets sv_projectDesc "My new ESX Legacy project"
|
||||
sets locale "en-US"
|
||||
sets tags "default, esx, legacy, Roleplay"
|
||||
sv_scriptHookAllowed 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user