Skip to content
This repository has been archived by the owner on Jul 11, 2021. It is now read-only.

Support for weight system #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ Config.OpenKey = Keys["Y"]

Config.OpenTime = 750

Config.UseLimitSystem = true -- If true, default old esx inventory limit system will be used, if set to false, new esx inventory weigh system will be used

-- Limit, unit can be whatever you want. Originally grams (as average people can hold 25kg)
Config.Limit = 25000

Expand Down
18 changes: 17 additions & 1 deletion server/esx_trunk-sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,22 @@ ESX.RegisterServerCallback(
end
)

function canPlayerCarryItem(targetItem, xPlayer, item, count)
if Config.UseLimitSystem then
if targetItem.limit == -1 or ((targetItem.count + count) <= targetItem.limit) then
return(true)
else
return(false)
end
else
if xPlayer.canCarryItem(item, count) then
return(true)
else
return(false)
end
end
end

RegisterServerEvent("esx_inventoryhud_trunk:getItem")
AddEventHandler(
"esx_inventoryhud_trunk:getItem",
Expand All @@ -107,7 +123,7 @@ AddEventHandler(

if type == "item_standard" then
local targetItem = xPlayer.getInventoryItem(item)
if targetItem.limit == -1 or ((targetItem.count + count) <= targetItem.limit) then
if canPlayerCarryItem(targetItem, xPlayer, item, count) then
TriggerEvent(
"esx_inventoryhud_trunk:getSharedDataStore",
plate,
Expand Down