mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
Make use of getItemLabel() in jim_bridge more
This commit is contained in:
@@ -115,12 +115,12 @@ function craftingMenu(data)
|
||||
local metaTable = {}
|
||||
-- Build ingredient details.
|
||||
for l, b in pairs(Recipes[i][tostring(k)]) do
|
||||
local label = Items[l] and Items[l].label or "error - "..l
|
||||
local label = getItemLabel(l)
|
||||
local hasItem = checkStashItem(data.stashName, { [l] = b })
|
||||
local missingMark = not hasItem and " ❌" or " "
|
||||
settext = settext..(settext ~= "" and br or "").."[ x"..b.." ] - "..label..missingMark
|
||||
|
||||
metaTable[Items[l] and Items[l].label or "error - "..l] = b
|
||||
metaTable[label] = b
|
||||
itemTable[l] = b
|
||||
end
|
||||
|
||||
@@ -128,7 +128,7 @@ function craftingMenu(data)
|
||||
Wait(10)
|
||||
end
|
||||
disable = not checkStashItem(data.stashName, itemTable)
|
||||
setheader = ((metadata and metadata.label) or (Items[tostring(k)] and Items[tostring(k)].label) or "error - "..tostring(k))
|
||||
setheader = ((metadata and metadata.label) or getItemLabel(k))
|
||||
..(Recipes[i]["amount"] > 1 and " x"..Recipes[i]["amount"] or "")
|
||||
|
||||
local statusEmoji = disable and " " or not canCarryTable[k] and " 📦" or " ✔️"
|
||||
@@ -359,7 +359,7 @@ function makeItem(data)
|
||||
return
|
||||
end
|
||||
if crafting and progressBar({
|
||||
label = "Using "..b.." "..Items[l].label,
|
||||
label = "Using "..b.." "..getItemLabel(l),
|
||||
time = 1000,
|
||||
cancel = true,
|
||||
dict = 'pickup_object',
|
||||
@@ -398,7 +398,7 @@ function makeItem(data)
|
||||
PlaySoundFromEntity(s.soundId, s.audioName, PlayerPedId(), s.audioRef, true, 0)
|
||||
end
|
||||
if crafting and progressBar({
|
||||
label = bartext..((metadata and metadata.label) or Items[data.item].label).." x"..craftAmount,
|
||||
label = bartext..((metadata and metadata.label) or getItemLabel(data.item)).." x"..craftAmount,
|
||||
time = totalBartime,
|
||||
cancel = true,
|
||||
dict = animDict,
|
||||
@@ -437,7 +437,7 @@ function makeItem(data)
|
||||
-- Run the original loop for multiple progress bars
|
||||
for i = 1, craftAmount do
|
||||
if crafting and progressBar({
|
||||
label = bartext..((metadata and metadata.label) or Items[data.item].label),
|
||||
label = bartext..((metadata and metadata.label) or getItemLabel(data.item)),
|
||||
time = bartime,
|
||||
cancel = true,
|
||||
dict = animDict,
|
||||
|
||||
@@ -1585,7 +1585,7 @@ RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount,
|
||||
|
||||
end
|
||||
else
|
||||
debugPrint("^6Bridge^7: ^3"..action.."^7["..invName.."] Player("..src..") "..Items[item].label.."("..item..") x"..(amount or 1))
|
||||
debugPrint("^6Bridge^7: ^3"..action.."^7["..invName.."] Player("..src..") "..getItemLabel(item).."("..item..") x"..(amount or 1))
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -1610,7 +1610,7 @@ RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount,
|
||||
ESX.GetPlayerFromId(src).addInventoryItem(item, amountToAdd)
|
||||
end
|
||||
else
|
||||
debugPrint("^6Bridge^7: ^3"..action.."^7["..invName.."] Player("..src..") "..Items[item].label.."("..item..") x"..(amount or 1))
|
||||
debugPrint("^6Bridge^7: ^3"..action.."^7["..invName.."] Player("..src..") "..getItemLabel(item).."("..item..") x"..(amount or 1))
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -1951,6 +1951,7 @@ end
|
||||
--- if doesItemExist(item) then print("item exists") end
|
||||
--- ```
|
||||
function doesItemExist(item)
|
||||
local item = type(item) == "string" and item or tostring(item)
|
||||
if not item or item == "" then
|
||||
return false
|
||||
end
|
||||
@@ -1965,16 +1966,18 @@ end
|
||||
|
||||
|
||||
function getItemLabel(item)
|
||||
local item = type(item) == "string" and item or tostring(item)
|
||||
|
||||
if not item or item == "" then
|
||||
return ""
|
||||
end
|
||||
if not Items or not next(Items) then
|
||||
return item.." (Missing)"
|
||||
return item.." (Missing item error)"
|
||||
end
|
||||
if Items[item] ~= nil then
|
||||
return Items[item].label
|
||||
end
|
||||
return item.." (Missing)"
|
||||
return item.." (Missing item error)"
|
||||
end
|
||||
|
||||
|
||||
@@ -2476,7 +2479,7 @@ function sellMenu(data)
|
||||
Menu[#Menu + 1] = {
|
||||
isMenuHeader = not hasTable[k].hasItem,
|
||||
icon = invImg(k),
|
||||
header = Items[k].label..(hasTable[k].hasItem and "💰 (x"..hasTable[k].count..")" or ""),
|
||||
header = getItemLabel(item)..(hasTable[k].hasItem and "💰 (x"..hasTable[k].count..")" or ""),
|
||||
txt = (Loc and Loc[Config.Lan]) and Loc[Config.Lan].info["sell_all"]..v.." "..Loc[Config.Lan].info["sell_each"]
|
||||
or "Sell ALL at $"..v.." each",
|
||||
onSelect = function()
|
||||
@@ -2534,7 +2537,7 @@ end
|
||||
--- ```
|
||||
function sellAnim(data, token)
|
||||
if not hasItem(data.item, 1) then
|
||||
triggerNotify(nil, Loc[Config.Lan].error["dont_have"].." "..Items[data.item].label, "error")
|
||||
triggerNotify(nil, Loc[Config.Lan].error["dont_have"].." "..getItemLabel(data.item), "error")
|
||||
return
|
||||
end
|
||||
|
||||
@@ -2596,7 +2599,7 @@ RegisterNetEvent(getScript()..":Sellitems", function(data, token)
|
||||
print((hasTable[data.item].count * data.price), data.price)
|
||||
fundPlayer((hasTable[data.item].count * data.price), "cash", src)
|
||||
else
|
||||
triggerNotify(nil, Loc[Config.Lan].error["dont_have"].." "..Items[data.item].label, "error", src)
|
||||
triggerNotify(nil, Loc[Config.Lan].error["dont_have"].." "..getItemLabel(data.item), "error", src)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user