-
Notifications
You must be signed in to change notification settings - Fork 190
05. Property support
Borea edited this page Jan 8, 2021
·
15 revisions
1a. Open
esx_property/client/main.lua` and do the following:
Find this code in OpenRoomMenu function:
table.insert(elements, {label = _U('remove_object'), value = 'room_inventory'})
table.insert(elements, {label = _U('deposit_object'), value = 'player_inventory'})
- And replace it with:
table.insert(elements, {label = "Property inventory", value = "property_inventory"})
- Then find this code:
elseif data.current.value == 'room_inventory' then
OpenRoomInventoryMenu(property, owner)
elseif data.current.value == 'player_inventory' then
OpenPlayerInventoryMenu(property, owner)
- And replace it with:
elseif data.current.value == "property_inventory" then
menu.close()
OpenPropertyInventoryMenu(property, owner)
- And finally add this function:
function OpenPropertyInventoryMenu(property, owner)
ESX.TriggerServerCallback("esx_property:getPropertyInventory", function(inventory)
TriggerEvent("DP_Inventory:openPropertyInventory", inventory)
end, owner)
end
2a. Add this to your database for cash money support: (You must upload the original esx_property .sql file first)
INSERT INTO `addon_account` (name, label, shared) VALUES
('property_money','Cash',0),
('property_black_money','Black Money',0)
;
3a. Open esx_property/server/main.lua
and do the following:
- Replace function
esx_property:getPropertyInventory
with
ESX.RegisterServerCallback('esx_property:getPropertyInventory', function(source, cb, owner)
local xPlayer = ESX.GetPlayerFromIdentifier(owner)
local blackMoney = 0
local money = 0
local items = {}
local weapons = {}
TriggerEvent('esx_addonaccount:getAccount', 'property_black_money', xPlayer.identifier, function(account)
blackMoney = account.money
end)
TriggerEvent('esx_addonaccount:getAccount', 'property_money', xPlayer.identifier, function(account)
money = account.money
end)
TriggerEvent('esx_addoninventory:getInventory', 'property', xPlayer.identifier, function(inventory)
items = inventory.items
end)
TriggerEvent('esx_datastore:getDataStore', 'property', xPlayer.identifier, function(store)
weapons = store.get('weapons') or {}
end)
cb({
blackMoney = blackMoney,
items = items,
money = money,
weapons = weapons
})
end)
- Replace
esx_property:getPlayerInventory
with
ESX.RegisterServerCallback('esx_property:getPlayerInventory', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
local blackMoney = xPlayer.getAccount('black_money').money
local money = xPlayer.getAccount('money').money
local items = xPlayer.inventory
cb({
blackMoney = blackMoney,
items = items,
money = money,
weapons = xPlayer.getLoadout()
})
end)
If you need additional support, please contact us through our Discord server.