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