mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 02:01:31 +00:00
Merge branch 'player-data' into inv
This commit is contained in:
@@ -196,6 +196,25 @@ if not Config.CustomInventory then
|
||||
end
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:addLoadoutItem", function(weaponName, weaponLabel, ammo)
|
||||
table.insert(ESX.PlayerData.loadout, {
|
||||
name = weaponName,
|
||||
ammo = ammo,
|
||||
label = weaponLabel,
|
||||
components = {},
|
||||
tintIndex = 0,
|
||||
})
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:removeLoadoutItem", function(weaponName, weaponLabel)
|
||||
for i = 1, #ESX.PlayerData.loadout do
|
||||
if ESX.PlayerData.loadout[i].name == weaponName then
|
||||
table.remove(ESX.PlayerData.loadout, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx:addWeapon", function()
|
||||
error("event ^5'esx:addWeapon'^1 Has Been Removed. Please use ^5xPlayer.addWeapon^1 Instead!")
|
||||
end)
|
||||
|
||||
@@ -48,6 +48,45 @@ if not IsDuplicityVersion() then -- Only register this event for the client
|
||||
ESX.PlayerData = {}
|
||||
end)
|
||||
|
||||
if not ESX.GetConfig("CustomInventory") then
|
||||
ESX.SecureNetEvent("esx:addInventoryItem", function(item, count, showNotification)
|
||||
for k, v in ipairs(ESX.PlayerData.inventory) do
|
||||
if v.name == item then
|
||||
ESX.PlayerData.inventory[k].count = count
|
||||
break
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:removeInventoryItem", function(item, count, showNotification)
|
||||
for i = 1, #ESX.PlayerData.inventory do
|
||||
if ESX.PlayerData.inventory[i].name == item then
|
||||
ESX.PlayerData.inventory[i].count = count
|
||||
break
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:addLoadoutItem", function(weaponName, weaponLabel, ammo)
|
||||
table.insert(ESX.PlayerData.loadout, {
|
||||
name = weaponName,
|
||||
ammo = ammo,
|
||||
label = weaponLabel,
|
||||
components = {},
|
||||
tintIndex = 0,
|
||||
})
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent("esx:removeLoadoutItem", function(weaponName, weaponLabel)
|
||||
for i = 1, #ESX.PlayerData.loadout do
|
||||
if ESX.PlayerData.loadout[i].name == weaponName then
|
||||
table.remove(ESX.PlayerData.loadout, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local external = { { "Class", "class.lua" }, { "Point", "point.lua" } }
|
||||
for i = 1, #external do
|
||||
local module = external[i]
|
||||
|
||||
@@ -580,6 +580,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
|
||||
GiveWeaponToPed(GetPlayerPed(self.source), joaat(weaponName), ammo, false, false)
|
||||
self.triggerEvent("esx:addInventoryItem", weaponLabel, false, true)
|
||||
self.triggerEvent("esx:addLoadoutItem", weaponName, weaponLabel, ammo)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -692,6 +693,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
|
||||
if weaponLabel then
|
||||
self.triggerEvent("esx:removeInventoryItem", weaponLabel, false, true)
|
||||
self.triggerEvent("esx:removeLoadoutItem", weaponName, weaponLabel)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -31,7 +31,11 @@ end
|
||||
---@param key? string Key pair to get specific value of config
|
||||
---@return unknown Returns the whole config if no key is passed, or a specific value
|
||||
function ESX.GetConfig(key)
|
||||
return key and Config[key] or Config
|
||||
if key then
|
||||
return Config[key]
|
||||
end
|
||||
|
||||
return Config
|
||||
end
|
||||
|
||||
---@param weaponName string
|
||||
|
||||
Reference in New Issue
Block a user