mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +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)
|
function self.getAccount(account)
|
||||||
for i=1, #self.accounts do
|
for i=1, #self.accounts do
|
||||||
if self.accounts[i].name == account then
|
if self.accounts[i].name == account then
|
||||||
return self.accounts[i], i
|
return self.accounts[i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -177,11 +177,11 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
if money >= 0 then
|
if money >= 0 then
|
||||||
local account, index = self.getAccount(accountName)
|
local account = self.getAccount(accountName)
|
||||||
|
|
||||||
if account then
|
if account then
|
||||||
money = account.round and ESX.Math.Round(money) or money
|
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)
|
self.triggerEvent('esx:setAccountMoney', account)
|
||||||
else
|
else
|
||||||
@@ -198,10 +198,10 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
if money > 0 then
|
if money > 0 then
|
||||||
local account, index = self.getAccount(accountName)
|
local account = self.getAccount(accountName)
|
||||||
if account then
|
if account then
|
||||||
money = account.round and ESX.Math.Round(money) or money
|
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)
|
self.triggerEvent('esx:setAccountMoney', account)
|
||||||
else
|
else
|
||||||
@@ -218,11 +218,11 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
if money > 0 then
|
if money > 0 then
|
||||||
local account, index = self.getAccount(accountName)
|
local account = self.getAccount(accountName)
|
||||||
|
|
||||||
if account then
|
if account then
|
||||||
money = account.round and ESX.Math.Round(money) or money
|
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)
|
self.triggerEvent('esx:setAccountMoney', account)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -131,8 +131,14 @@ function loadESXPlayer(identifier, playerId, isNew)
|
|||||||
if data.round == nil then
|
if data.round == nil then
|
||||||
data.round = true
|
data.round = true
|
||||||
end
|
end
|
||||||
userData.accounts[#userData.accounts + 1] = {name = account, money = foundAccounts[account] or Config.StartingAccountMoney[account] or 0,
|
local index = #userData.accounts + 1
|
||||||
label = data.label, round = data.round}
|
userData.accounts[index] = {
|
||||||
|
name = account,
|
||||||
|
money = foundAccounts[account] or Config.StartingAccountMoney[account] or 0,
|
||||||
|
label = data.label,
|
||||||
|
round = data.round,
|
||||||
|
index = index
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Job
|
-- Job
|
||||||
|
|||||||
@@ -12,11 +12,7 @@ CreateThread(function()
|
|||||||
name = name,
|
name = name,
|
||||||
data = data
|
data = data
|
||||||
})
|
})
|
||||||
|
SetNuiFocus(true, true)
|
||||||
ESX.SetTimeout(200, function()
|
|
||||||
SetNuiFocus(true, true)
|
|
||||||
end)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function closeMenu(namespace, name)
|
local function closeMenu(namespace, name)
|
||||||
@@ -46,11 +42,9 @@ CreateThread(function()
|
|||||||
|
|
||||||
RegisterNUICallback('menu_submit', function(data, cb)
|
RegisterNUICallback('menu_submit', function(data, cb)
|
||||||
local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name)
|
local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name)
|
||||||
|
if menu.submit then
|
||||||
if menu.submit ~= nil then
|
|
||||||
menu.submit(data, menu)
|
menu.submit(data, menu)
|
||||||
end
|
end
|
||||||
|
|
||||||
cb('OK')
|
cb('OK')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -122,6 +122,7 @@
|
|||||||
let menu = $(Mustache.render(MenuTpl, view));
|
let menu = $(Mustache.render(MenuTpl, view));
|
||||||
|
|
||||||
menu.find('button[data-namespace][data-name]').click(function() {
|
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'), {
|
ESX_MENU.submit($(this).data('namespace'), $(this).data('name'), {
|
||||||
data : ESX_MENU.data[$(this).data('namespace')][$(this).data('name')][parseInt($(this).data('id'))],
|
data : ESX_MENU.data[$(this).data('namespace')][$(this).data('name')][parseInt($(this).data('id'))],
|
||||||
value: $(this).data('value')
|
value: $(this).data('value')
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ CreateThread(function()
|
|||||||
ESX.ShowHelpNotification(v.Hint)
|
ESX.ShowHelpNotification(v.Hint)
|
||||||
hintIsShowed = true
|
hintIsShowed = true
|
||||||
if IsControlJustReleased(0, 38) then
|
if IsControlJustReleased(0, 38) then
|
||||||
ESX.Game.Teleport(PlayerPedId(), position)
|
ESX.Game.Teleport(PlayerPedId(), v.Teleport)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ Locales['nl'] = {
|
|||||||
['box'] = 'Box',
|
['box'] = 'Box',
|
||||||
['fence'] = 'PD Hek',
|
['fence'] = 'PD Hek',
|
||||||
['cash'] = 'Pallet met geld',
|
['cash'] = 'Pallet met geld',
|
||||||
|
['spikestrips'] = 'Spijkermatten',
|
||||||
-- ID Menu
|
-- ID Menu
|
||||||
['name'] = 'Naam: %s',
|
['name'] = 'Naam: %s',
|
||||||
['job'] = 'Werk: %s',
|
['job'] = 'Werk: %s',
|
||||||
|
|||||||
@@ -877,7 +877,7 @@ function OpenPMQuickMenu(Action)
|
|||||||
end
|
end
|
||||||
|
|
||||||
ESX.RegisterInput(_U("realestate_command"), _U("realestate_command_desc"), "keyboard", "F5", function()
|
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
|
if Access then
|
||||||
OpenPMQuickMenu("ActionsMenu")
|
OpenPMQuickMenu("ActionsMenu")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ Config.OwnedBlips = true -- Add blips for Owned Properties
|
|||||||
--------------------- General Settings ---------------------------------
|
--------------------- General Settings ---------------------------------
|
||||||
Config.Locale = 'en'
|
Config.Locale = 'en'
|
||||||
Config.Shells = false -- Enable/Disable Shell Interiors Default: false
|
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.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.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
|
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",
|
["cctv_textui_3"] = "Press ~b~[E]~s~ to Set Max Left Roation",
|
||||||
["create_success"] = "Property created!",
|
["create_success"] = "Property created!",
|
||||||
["missing_data"] = "Please Fill Out all Required Inputs!",
|
["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()
|
PropertiesRefresh()
|
||||||
end, false, {help = _U("refresh_desc")})
|
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)
|
ESX.RegisterCommand(_("create_name"), "user", function(xPlayer)
|
||||||
if IsPlayerAdmin(xPlayer.source) or (PM.Enabled and xPlayer.job.name == PM.job) then
|
if IsPlayerAdmin(xPlayer.source) or (PM.Enabled and xPlayer.job.name == PM.job) then
|
||||||
xPlayer.triggerEvent("esx_property:CreateProperty")
|
xPlayer.triggerEvent("esx_property:CreateProperty")
|
||||||
@@ -1031,7 +1025,7 @@ AddEventHandler('playerDropped', function()
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
ESX.RegisterServerCallback('esx_property:CanCreateProperty', function(source, cb, num)
|
ESX.RegisterServerCallback('esx_property:CanCreateProperty', function(source, cb)
|
||||||
local Re = false
|
local Re = false
|
||||||
local xPlayer = ESX.GetPlayerFromId(source)
|
local xPlayer = ESX.GetPlayerFromId(source)
|
||||||
|
|
||||||
@@ -1044,10 +1038,16 @@ ESX.RegisterServerCallback('esx_property:CanCreateProperty', function(source, cb
|
|||||||
cb(Re)
|
cb(Re)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
ESX.RegisterServerCallback('esx_property:IsAdmin', function(source, cb, num)
|
ESX.RegisterServerCallback('esx_property:IsAdmin', function(source, cb)
|
||||||
cb(IsPlayerAdmin(source, "ViewProperties"))
|
cb(IsPlayerAdmin(source, "ViewProperties"))
|
||||||
end)
|
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)
|
RegisterNetEvent('esx_property:server:createProperty', function(Property)
|
||||||
local source = source
|
local source = source
|
||||||
local xPlayer = ESX.GetPlayerFromId(source)
|
local xPlayer = ESX.GetPlayerFromId(source)
|
||||||
@@ -1088,24 +1088,36 @@ AddEventHandler('txAdmin:events:scheduledRestart', function(eventData)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--- Save Properties On Server Stop/Restart
|
function PropertySave(Reason)
|
||||||
AddEventHandler('txAdmin:events:serverShuttingDown', function()
|
|
||||||
if Properties and #Properties > 0 then
|
if Properties and #Properties > 0 then
|
||||||
SaveResourceFile(GetCurrentResourceName(), 'properties.json', json.encode(Properties))
|
SaveResourceFile(GetCurrentResourceName(), 'properties.json', json.encode(Properties))
|
||||||
Log("Properties Saving", 11141375,
|
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
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Save Properties On Server Stop/Restart
|
||||||
|
AddEventHandler('txAdmin:events:serverShuttingDown', function()
|
||||||
|
PropertySave(_U("server_shutdown"))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--- Save Properties On Resource Stop/Restart
|
--- Save Properties On Resource Stop/Restart
|
||||||
|
|
||||||
AddEventHandler('onResourceStop', function(ResourceName)
|
AddEventHandler('onResourceStop', function(ResourceName)
|
||||||
if ResourceName == GetCurrentResourceName() then
|
if ResourceName == GetCurrentResourceName() then
|
||||||
if Properties and #Properties > 0 then
|
PropertySave(_U("resource_stop"))
|
||||||
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
|
|
||||||
end
|
end
|
||||||
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
|
sv_maxclients 10 # Allow access to features usually locked behind a FiveM patreon key
|
||||||
|
|
||||||
sets sv_projectName "ESX Legacy"
|
sets sv_projectName "ESX Legacy"
|
||||||
sets sv_projectDesc ""
|
sets sv_projectDesc "My new ESX Legacy project"
|
||||||
sets locale "en-GB"
|
sets locale "en-US"
|
||||||
sets tags "default, esx, legacy, Roleplay"
|
sets tags "default, esx, legacy, Roleplay"
|
||||||
sv_scriptHookAllowed 0
|
sv_scriptHookAllowed 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user