mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-19 14:56:02 +01:00
Compare commits
9 Commits
145e3aa156
...
v2.1.05
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26b1f36029 | ||
|
|
331dc94e2f | ||
|
|
d1dab48acc | ||
|
|
7e595df143 | ||
|
|
d791a2e09f | ||
|
|
7738bb4fca | ||
|
|
3ad65810c3 | ||
|
|
45eeaf8f0d | ||
|
|
37f7eb1116 |
@@ -1,6 +1,6 @@
|
|||||||
name "Jim_Bridge"
|
name "Jim_Bridge"
|
||||||
author "Jimathy"
|
author "Jimathy"
|
||||||
version "2.1.03"
|
version "2.1.05"
|
||||||
description "Framework Bridge By Jimathy"
|
description "Framework Bridge By Jimathy"
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
|
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ local excludeKeys = {
|
|||||||
amount = true, metadata = true, description = true, info = true,
|
amount = true, metadata = true, description = true, info = true,
|
||||||
job = true, gang = true, oneUse = true, slot = true,
|
job = true, gang = true, oneUse = true, slot = true,
|
||||||
blueprintRef = true, craftingLevel = true, craftedItems = true,
|
blueprintRef = true, craftingLevel = true, craftedItems = true,
|
||||||
hasCrafted = true, exp = true, anim = true, time = true,
|
hasCrafted = true, exp = true, anim = true, time = true, id = true,
|
||||||
|
ingredients = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
-------------------------------------------------------------
|
-------------------------------------------------------------
|
||||||
@@ -40,9 +41,14 @@ local excludeKeys = {
|
|||||||
--- craftable = {
|
--- craftable = {
|
||||||
--- Header = "Weapon Crafting",
|
--- Header = "Weapon Crafting",
|
||||||
--- Recipes = {
|
--- Recipes = {
|
||||||
--- [1] = {
|
--- weapon_pistol = {
|
||||||
--- ["weapon_pistol"] = { ["steel"] = 5, ["plastic"] = 2 },
|
--- id = 1,
|
||||||
--- amount = 1,
|
--- ingredients = {
|
||||||
|
--- steel = 5, plastic = 5,
|
||||||
|
--- },
|
||||||
|
--- info = {
|
||||||
|
--- amount = 1,
|
||||||
|
--- },
|
||||||
--- },
|
--- },
|
||||||
--- -- More recipes...
|
--- -- More recipes...
|
||||||
--- },
|
--- },
|
||||||
@@ -56,9 +62,10 @@ local excludeKeys = {
|
|||||||
--- job = "mechanic",
|
--- job = "mechanic",
|
||||||
--- onBack = function() print("Returning to previous menu") end,
|
--- onBack = function() print("Returning to previous menu") end,
|
||||||
--- })
|
--- })
|
||||||
|
--- ```
|
||||||
function craftingMenu(data)
|
function craftingMenu(data)
|
||||||
if CraftLock then return end
|
if CraftLock then return end
|
||||||
|
local data = cloneTable(data)
|
||||||
-- Job or gang check; exit if not authorized.
|
-- Job or gang check; exit if not authorized.
|
||||||
if (data.job or data.gang) and not jobCheck(data.job or data.gang) then return end
|
if (data.job or data.gang) and not jobCheck(data.job or data.gang) then return end
|
||||||
|
|
||||||
@@ -72,16 +79,49 @@ function craftingMenu(data)
|
|||||||
-- Normalize stash name.
|
-- Normalize stash name.
|
||||||
data.stashName = data.stashTable or data.stashName
|
data.stashName = data.stashTable or data.stashName
|
||||||
|
|
||||||
local Menu = {}
|
-- Wrapper to convert old style crafting recipes to be handled by the menu properly
|
||||||
local Recipes = data.craftable.Recipes
|
--if data.craftable.Recipes[1] then -- assume old style crafting table
|
||||||
local craftedItems = {}
|
-- local compatTable = {}
|
||||||
local tempCarryTable = {}
|
-- local id = 0
|
||||||
|
-- for k, v in ipairs(data.craftable.Recipes) do
|
||||||
|
-- local Recipe = v
|
||||||
|
-- for l, b in pairs(Recipe) do
|
||||||
|
-- if doesItemExist(l) then
|
||||||
|
-- id += 1
|
||||||
|
-- compatTable[l] = {
|
||||||
|
-- ingredients = b,
|
||||||
|
-- id = id,
|
||||||
|
-- info = {
|
||||||
|
-- amount = Recipe.amount or 1,
|
||||||
|
-- metadata = Recipe.metadata or nil,
|
||||||
|
-- job = Recipe.job or nil,
|
||||||
|
-- gang = Recipe.gang or nil,
|
||||||
|
-- hasCrafted = Recipe.hasCrafted or nil,
|
||||||
|
-- },
|
||||||
|
-- }
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- data.craftable.Recipes = compatTable
|
||||||
|
--end
|
||||||
|
|
||||||
-- Build a table of all required ingredients (default quantity is 1).
|
-- Convert to array
|
||||||
|
--local RecipesArray = {}
|
||||||
|
--for k, v in pairs(data.craftable.Recipes) do
|
||||||
|
-- RecipesArray[v.id] = { [k] = v }
|
||||||
|
--end
|
||||||
|
|
||||||
|
local Menu = {}
|
||||||
|
local Recipes = cloneTable(data.craftable.Recipes)
|
||||||
|
local craftedItems = {}
|
||||||
|
|
||||||
|
local tempCarryTable = {}
|
||||||
|
-- Build a temporary table of all required ingredients (default quantity is 1).
|
||||||
for i = 1, #Recipes do
|
for i = 1, #Recipes do
|
||||||
for k in pairs(Recipes[i]) do
|
for k, v in pairs(Recipes[i]) do
|
||||||
if k ~= "amount" and k ~= "metadata" and k ~= "job" and k ~= "gang" then
|
if not excludeKeys[k] then
|
||||||
tempCarryTable[k] = Recipes[i].amount or 1
|
if not Recipes[i].amount then Recipes[i].amount = 1 end
|
||||||
|
tempCarryTable[k] = tempCarryTable[k] and (tempCarryTable[k] < Recipes[i].amount) or Recipes[i].amount
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -96,76 +136,91 @@ function craftingMenu(data)
|
|||||||
header = "Material Source: "..(usingStash and "Job Stash" or "Player Inventory"),
|
header = "Material Source: "..(usingStash and "Job Stash" or "Player Inventory"),
|
||||||
disabled = true,
|
disabled = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Process each recipe to create menu entries.
|
|
||||||
for i = 1, #Recipes do
|
for i = 1, #Recipes do
|
||||||
if not Recipes[i]["amount"] then Recipes[i]["amount"] = 1 end
|
local menuId = #Menu+1
|
||||||
for k, _ in pairs(Recipes[i]) do
|
local item = ""
|
||||||
|
local Recipe = {}
|
||||||
|
for k, v in pairs(Recipes[i]) do
|
||||||
if not excludeKeys[k] then
|
if not excludeKeys[k] then
|
||||||
local hasjob = true
|
item = k
|
||||||
if Recipes[i].job then
|
Recipe = Recipes[i]
|
||||||
for l, b in pairs(Recipes[i].job) do
|
Recipe.amount = Recipe.amount or 1
|
||||||
hasjob = hasJob(l, nil, b)
|
break
|
||||||
if hasjob then break end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if hasjob then
|
|
||||||
local setheader, settext, disable, metadata = "", "", false, (Recipes[i]["metadata"] or Recipes[i]["info"] or nil)
|
|
||||||
local itemTable = {}
|
|
||||||
local metaTable = {}
|
|
||||||
-- Build ingredient details.
|
|
||||||
for l, b in pairs(Recipes[i][tostring(k)]) do
|
|
||||||
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[label] = b
|
|
||||||
itemTable[l] = b
|
|
||||||
end
|
|
||||||
|
|
||||||
while not canCarryTable do
|
|
||||||
Wait(10)
|
|
||||||
end
|
|
||||||
disable = not checkStashItem(data.stashName, itemTable)
|
|
||||||
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 " ✔️"
|
|
||||||
local isNew = (Recipes[i]["hasCrafted"] ~= nil and craftedItems[k] == nil) and "✨ " or ""
|
|
||||||
setheader = isNew .. setheader .. statusEmoji
|
|
||||||
|
|
||||||
Menu[#Menu + 1] = {
|
|
||||||
arrow = isOx() and (not disable and canCarryTable[k]),
|
|
||||||
isMenuHeader = disable or not canCarryTable[k],
|
|
||||||
icon = invImg((metadata and metadata.image) or tostring(k)),
|
|
||||||
image = invImg((metadata and metadata.image) or tostring(k)),
|
|
||||||
header = setheader,
|
|
||||||
txt = settext or nil,
|
|
||||||
metadata = metaTable,
|
|
||||||
onSelect = (not disable and canCarryTable[k]) and function()
|
|
||||||
local transdata = {
|
|
||||||
item = k,
|
|
||||||
craft = data.craftable.Recipes[i],
|
|
||||||
craftable = data.craftable,
|
|
||||||
coords = data.coords,
|
|
||||||
stashName = data.stashName,
|
|
||||||
onBack = data.onBack,
|
|
||||||
metadata = metadata,
|
|
||||||
}
|
|
||||||
if Config.Crafting.MultiCraft then
|
|
||||||
multiCraft(transdata)
|
|
||||||
else
|
|
||||||
makeItem(transdata)
|
|
||||||
end
|
|
||||||
end or nil,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
--Wait(0)
|
end
|
||||||
|
|
||||||
|
-- Job Check
|
||||||
|
local hasGroup = true
|
||||||
|
if Recipe.job then
|
||||||
|
for l, b in pairs(Recipe.job) do
|
||||||
|
hasGroup = hasJob(l, nil, b)
|
||||||
|
if hasGroup then goto skipcheck end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if Recipe.gang then
|
||||||
|
for l, b in pairs(Recipe.gang) do
|
||||||
|
hasGroup = hasJob(l, nil, b)
|
||||||
|
if hasGroup then goto skipcheck end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
::skipcheck::
|
||||||
|
|
||||||
|
-- if has group requirement, continue
|
||||||
|
if hasGroup then
|
||||||
|
local setheader, settext, disable, metadata = "", "", false, (Recipe.metadata or Recipe.info or nil)
|
||||||
|
local itemTable = {}
|
||||||
|
local metaTable = {}
|
||||||
|
-- Build ingredient details.
|
||||||
|
for l, b in pairs(Recipe[item]) do
|
||||||
|
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[label] = b
|
||||||
|
itemTable[l] = b
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Make sure "canCarryTable" exists
|
||||||
|
while not canCarryTable do Wait(10) end
|
||||||
|
disable = not checkStashItem(data.stashName, itemTable)
|
||||||
|
setheader = ((metadata and metadata.label) or getItemLabel(item))
|
||||||
|
..(Recipe.amount > 1 and " x"..Recipe.amount or "")
|
||||||
|
|
||||||
|
local statusEmoji = disable and " " or not canCarryTable[item] and " 📦" or " ✔️"
|
||||||
|
local isNew = (Recipe.hasCrafted ~= nil and craftedItems[item] == nil) and "✨ " or ""
|
||||||
|
setheader = isNew .. setheader .. statusEmoji
|
||||||
|
|
||||||
|
-- Build menu option using info
|
||||||
|
Menu[menuId] = {
|
||||||
|
arrow = isOx() and (not disable and canCarryTable[item]),
|
||||||
|
isMenuHeader = disable or not canCarryTable[item],
|
||||||
|
icon = invImg((metadata and metadata.image) or item),
|
||||||
|
image = invImg((metadata and metadata.image) or item),
|
||||||
|
header = setheader,
|
||||||
|
txt = settext or nil,
|
||||||
|
metadata = metaTable,
|
||||||
|
onSelect = (not disable and canCarryTable[item]) and function()
|
||||||
|
local transdata = {
|
||||||
|
item = item,
|
||||||
|
craft = Recipe,
|
||||||
|
craftable = data.craftable,
|
||||||
|
coords = data.coords,
|
||||||
|
amount = Recipe.amount,
|
||||||
|
stashName = data.stashName,
|
||||||
|
onBack = data.onBack,
|
||||||
|
metadata = metadata,
|
||||||
|
}
|
||||||
|
if Config.Crafting.MultiCraft then
|
||||||
|
multiCraft(transdata)
|
||||||
|
else
|
||||||
|
makeItem(transdata)
|
||||||
|
end
|
||||||
|
end or nil,
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- open context menu
|
||||||
openMenu(Menu, {
|
openMenu(Menu, {
|
||||||
header = data.craftable.Header,
|
header = data.craftable.Header,
|
||||||
headertxt = data.craftable.Headertxt,
|
headertxt = data.craftable.Headertxt,
|
||||||
@@ -322,7 +377,10 @@ end
|
|||||||
--- })
|
--- })
|
||||||
--- ```
|
--- ```
|
||||||
|
|
||||||
function makeItem(data)
|
function makeItem(origData)
|
||||||
|
|
||||||
|
local data = cloneTable(origData)
|
||||||
|
|
||||||
local Ped = PlayerPedId()
|
local Ped = PlayerPedId()
|
||||||
if CraftLock then return end
|
if CraftLock then return end
|
||||||
CraftLock = true
|
CraftLock = true
|
||||||
@@ -337,112 +395,58 @@ function makeItem(data)
|
|||||||
local craftAmount = (data.amount and data.amount ~= 1) and data.amount or 1
|
local craftAmount = (data.amount and data.amount ~= 1) and data.amount or 1
|
||||||
local metadata = data.metadata or nil
|
local metadata = data.metadata or nil
|
||||||
local prop = data.craftable.Anims and data.craftable.Anims.prop or nil
|
local prop = data.craftable.Anims and data.craftable.Anims.prop or nil
|
||||||
|
|
||||||
local canReturn = true
|
local canReturn = true
|
||||||
|
|
||||||
local crafted, crafting = true, true
|
local crafted, crafting = true, true
|
||||||
local cam = createTempCam(Ped, data.coords)
|
local cam = createCam(Ped, data.coords.xyz)
|
||||||
startTempCam(cam)
|
startCam(cam, 5000)
|
||||||
|
|
||||||
-- Calculate total bartime if SingleProgress is enabled
|
-- Calculate total bartime if SingleProgress is enabled
|
||||||
local totalBartime = (bartime * craftAmount)
|
local totalBartime = (bartime * craftAmount)
|
||||||
|
|
||||||
|
local craftProp = nil
|
||||||
|
if prop then
|
||||||
|
craftProp = makeProp({ prop = prop.model, coords = GetEntityCoords(PlayerPedId()), true, true })
|
||||||
|
AttachEntityToEntity(craftProp, Ped, GetPedBoneIndex(Ped, prop.bone), prop.pos.x, prop.pos.y, prop.pos.z, prop.rot.x, prop.rot.y, prop.rot.z, true, true, false, true, 1, true)
|
||||||
|
end
|
||||||
|
if data.sound then
|
||||||
|
local s = data.sound
|
||||||
|
PlaySoundFromEntity(s.soundId, s.audioName, Ped, s.audioRef, true, 0)
|
||||||
|
end
|
||||||
if not Config.Crafting.SingleProgress then -- if SingleProgress is disabled, dont do ingredient progressbars
|
if not Config.Crafting.SingleProgress then -- if SingleProgress is disabled, dont do ingredient progressbars
|
||||||
-- Run ingredient check and usage separately first
|
-- Run ingredient check and usage separately first
|
||||||
for i = 1, craftAmount do
|
for i = 1, craftAmount do
|
||||||
for k, v in pairs(data.craft) do
|
|
||||||
if not excludeKeys[k] and type(v) == "table" then
|
|
||||||
for l, b in pairs(v) do
|
|
||||||
if isInventoryOpen() then
|
|
||||||
print("^1Error^7: ^2Inventory is open, you tried to break things")
|
|
||||||
stopTempCam()
|
|
||||||
ClearPedTasks(Ped)
|
|
||||||
if canReturn then craftingMenu(data) end
|
|
||||||
CraftLock = false
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if crafting and progressBar({
|
|
||||||
label = "Using "..b.." "..getItemLabel(l),
|
|
||||||
time = 800,
|
|
||||||
cancel = true,
|
|
||||||
dict = 'pickup_object',
|
|
||||||
anim = "putdown_low",
|
|
||||||
flag = 49,
|
|
||||||
icon = l,
|
|
||||||
}) then
|
|
||||||
TriggerEvent((isStarted(QBInv) and QBInvNew and "qb-" or "")..'inventory:client:ItemBox', Items[l], "use", b)
|
|
||||||
else
|
|
||||||
crafted, crafting = false, false
|
|
||||||
break
|
|
||||||
end
|
|
||||||
Wait(200)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if not crafted then
|
|
||||||
stopTempCam()
|
|
||||||
ClearPedTasks(Ped)
|
|
||||||
if canReturn then craftingMenu(data) end
|
|
||||||
CraftLock = false
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Handle SingleProgress option
|
|
||||||
if Config.Crafting.SingleProgress then
|
|
||||||
local craftProp = nil
|
|
||||||
if prop then
|
|
||||||
craftProp = makeProp({ prop = prop.model, coords = vec4(0, 0, 0, 0), true, true })
|
|
||||||
AttachEntityToEntity(craftProp, Ped, GetPedBoneIndex(Ped, prop.bone), prop.pos.x, prop.pos.y, prop.pos.z, prop.rot.x, prop.rot.y, prop.rot.z, true, true, false, true, 1, true)
|
|
||||||
end
|
|
||||||
if data.sound then
|
|
||||||
local s = data.sound
|
|
||||||
PlaySoundFromEntity(s.soundId, s.audioName, Ped, s.audioRef, true, 0)
|
|
||||||
end
|
|
||||||
if crafting and progressBar({
|
|
||||||
label = bartext..((metadata and metadata.label) or getItemLabel(data.item)).." x"..craftAmount,
|
|
||||||
time = totalBartime,
|
|
||||||
cancel = true,
|
|
||||||
dict = animDict,
|
|
||||||
anim = anim,
|
|
||||||
flag = 49,
|
|
||||||
icon = data.item,
|
|
||||||
request = true,
|
|
||||||
}) then
|
|
||||||
data.craft.amount = craftAmount
|
|
||||||
for k, v in pairs(data.craft[data.item]) do
|
for k, v in pairs(data.craft[data.item]) do
|
||||||
-- multiply igredient requirement in sent crafting table for removal
|
if isInventoryOpen() then
|
||||||
data.craft[data.item][k] = (v * craftAmount)
|
print("^1Error^7: ^2Inventory is open, you tried to break things")
|
||||||
|
stopCam(0)
|
||||||
|
ClearPedTasks(Ped)
|
||||||
|
if canReturn then craftingMenu(origData) end
|
||||||
|
CraftLock = false
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if crafting and progressBar({
|
||||||
|
label = "Using "..v.." "..getItemLabel(k),
|
||||||
|
time = 800,
|
||||||
|
cancel = true,
|
||||||
|
dict = 'pickup_object',
|
||||||
|
anim = "putdown_low",
|
||||||
|
flag = 49,
|
||||||
|
icon = k,
|
||||||
|
}) then
|
||||||
|
TriggerEvent((isStarted(QBInv) and QBInvNew and "qb-" or "")..'inventory:client:ItemBox', Items[k], "use", v)
|
||||||
|
else
|
||||||
|
crafted, crafting = false, false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
Wait(200)
|
||||||
end
|
end
|
||||||
TriggerServerEvent(getScript()..":Crafting:GetItem", data.item, data.craft, data.stashName, metadata, currentToken)
|
|
||||||
currentToken = nil -- clear client cached token
|
if not crafted then
|
||||||
-- handle metadata and experience in a single go
|
goto finishEarly
|
||||||
if data.craft["hasCrafted"] ~= nil then
|
|
||||||
data.craftable.craftedItems[data.item] = true
|
|
||||||
triggerCallback(getScript()..":server:setPlayerMetadata", "craftedItems", data.craftable.craftedItems)
|
|
||||||
end
|
end
|
||||||
if data.craft["exp"] ~= nil then
|
|
||||||
craftingLevel += data.craft["exp"].give * craftAmount
|
|
||||||
triggerCallback(getScript()..":server:setPlayerMetadata", "craftingLevel", craftingLevel)
|
|
||||||
end
|
|
||||||
if data.craftable.Recipes[1].oneUse == true then
|
|
||||||
removeItem("craftrecipe", 1, nil, data.craftable.Recipes[1].slot)
|
|
||||||
local breakId = GetSoundId()
|
|
||||||
PlaySoundFromEntity(breakId, "Drill_Pin_Break", Ped, "DLC_HEIST_FLEECA_SOUNDSET", 1, 0)
|
|
||||||
canReturn = false
|
|
||||||
end
|
|
||||||
if data.sound then
|
|
||||||
StopSound(data.sound.soundId)
|
|
||||||
end
|
|
||||||
if data.requiredItemfunc then
|
|
||||||
data.requiredItemfunc()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if craftProp then destroyProp(craftProp) end
|
|
||||||
else
|
|
||||||
-- Run the original loop for multiple progress bars
|
|
||||||
for i = 1, craftAmount do
|
|
||||||
if crafting and progressBar({
|
if crafting and progressBar({
|
||||||
label = bartext..((metadata and metadata.label) or getItemLabel(data.item)),
|
label = bartext..((metadata and metadata.label) or getItemLabel(data.item)),
|
||||||
time = bartime,
|
time = bartime,
|
||||||
@@ -455,12 +459,12 @@ function makeItem(data)
|
|||||||
}) then
|
}) then
|
||||||
TriggerServerEvent(getScript()..":Crafting:GetItem", data.item, data.craft, data.stashName, metadata, currentToken)
|
TriggerServerEvent(getScript()..":Crafting:GetItem", data.item, data.craft, data.stashName, metadata, currentToken)
|
||||||
currentToken = nil
|
currentToken = nil
|
||||||
if data.craft["hasCrafted"] ~= nil then
|
if data.craft.hasCrafted ~= nil then
|
||||||
data.craftable.craftedItems[data.item] = true
|
data.craftable.craftedItems[data.item] = true
|
||||||
triggerCallback(getScript()..":server:setPlayerMetadata", "craftedItems", data.craftable.craftedItems)
|
triggerCallback(getScript()..":server:setPlayerMetadata", "craftedItems", data.craftable.craftedItems)
|
||||||
end
|
end
|
||||||
if data.craft["exp"] ~= nil then
|
if data.craft.exp ~= nil then
|
||||||
craftingLevel += data.craft["exp"].give
|
craftingLevel += data.craft.exp.give
|
||||||
triggerCallback(getScript()..":server:setPlayerMetadata", "craftingLevel", craftingLevel)
|
triggerCallback(getScript()..":server:setPlayerMetadata", "craftingLevel", craftingLevel)
|
||||||
end
|
end
|
||||||
if data.craftable.Recipes[1].oneUse == true then
|
if data.craftable.Recipes[1].oneUse == true then
|
||||||
@@ -469,19 +473,60 @@ function makeItem(data)
|
|||||||
PlaySoundFromEntity(breakId, "Drill_Pin_Break", Ped, "DLC_HEIST_FLEECA_SOUNDSET", 1, 0)
|
PlaySoundFromEntity(breakId, "Drill_Pin_Break", Ped, "DLC_HEIST_FLEECA_SOUNDSET", 1, 0)
|
||||||
canReturn = false
|
canReturn = false
|
||||||
end
|
end
|
||||||
if data.requiredItemfunc then
|
|
||||||
data.requiredItemfunc()
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if crafting and progressBar({
|
||||||
|
label = bartext..((metadata and metadata.label) or getItemLabel(data.item)).." x"..craftAmount,
|
||||||
|
time = totalBartime,
|
||||||
|
cancel = true,
|
||||||
|
dict = animDict,
|
||||||
|
anim = anim,
|
||||||
|
flag = 49,
|
||||||
|
icon = data.item,
|
||||||
|
request = true,
|
||||||
|
}) then
|
||||||
|
data.craft.amount *= craftAmount
|
||||||
|
for k, v in pairs(data.craft[data.item]) do
|
||||||
|
-- multiply igredient requirement in sent crafting table for removal
|
||||||
|
data.craft[data.item][k] = (v * craftAmount)
|
||||||
|
end
|
||||||
|
TriggerServerEvent(getScript()..":Crafting:GetItem", data.item, data.craft, data.stashName, metadata, currentToken)
|
||||||
|
currentToken = nil -- clear client cached token
|
||||||
|
-- handle metadata and experience in a single go
|
||||||
|
if data.craft.hasCrafted ~= nil then
|
||||||
|
data.craftable.craftedItems[data.item] = true
|
||||||
|
triggerCallback(getScript()..":server:setPlayerMetadata", "craftedItems", data.craftable.craftedItems)
|
||||||
|
end
|
||||||
|
if data.craft.exp ~= nil then
|
||||||
|
craftingLevel += data.craft["exp"].give * craftAmount
|
||||||
|
triggerCallback(getScript()..":server:setPlayerMetadata", "craftingLevel", craftingLevel)
|
||||||
|
end
|
||||||
|
--if data.craft.Recipes[1].oneUse == true then
|
||||||
|
-- removeItem("craftrecipe", 1, nil, data.craftable.Recipes[1].slot)
|
||||||
|
-- local breakId = GetSoundId()
|
||||||
|
-- PlaySoundFromEntity(breakId, "Drill_Pin_Break", Ped, "DLC_HEIST_FLEECA_SOUNDSET", 1, 0)
|
||||||
|
-- canReturn = false
|
||||||
|
--end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
::finishEarly::
|
||||||
|
if craftProp then destroyProp(craftProp) end
|
||||||
|
|
||||||
Wait(500)
|
if data.sound then
|
||||||
stopTempCam()
|
StopSound(data.sound.soundId)
|
||||||
|
end
|
||||||
|
if data.requiredItemfunc then
|
||||||
|
data.requiredItemfunc()
|
||||||
|
end
|
||||||
|
|
||||||
|
--Wait(500)
|
||||||
|
stopCam(0)
|
||||||
CraftLock = false
|
CraftLock = false
|
||||||
if canReturn then craftingMenu(data) end
|
if canReturn then craftingMenu(origData) end
|
||||||
ClearPedTasks(Ped)
|
ClearPedTasks(Ped)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -512,14 +557,13 @@ RegisterNetEvent(getScript()..":Crafting:GetItem", function(ItemMake, craftable,
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local hasItems, hasTable = hasItem(ItemMake, 1, src)
|
local hasItems, hasTable = hasItem(ItemMake, 1, src)
|
||||||
if stashName then
|
if stashName then
|
||||||
local itemRemove = {}
|
local itemRemove = {}
|
||||||
if type(stashName) == "table" then
|
if type(stashName) == "table" then
|
||||||
for _, name in pairs(stashName) do
|
for _, name in pairs(stashName) do
|
||||||
stashItems = getStash(name)
|
stashItems = getStash(name)
|
||||||
for k, v in pairs(craftable[ItemMake] or {}) do
|
for k, v in pairs(craftable[ItemMake]) do
|
||||||
for _, b in pairs(stashItems or {}) do
|
for _, b in pairs(stashItems or {}) do
|
||||||
if k == b.name then
|
if k == b.name then
|
||||||
itemRemove[k] = v
|
itemRemove[k] = v
|
||||||
@@ -529,7 +573,7 @@ RegisterNetEvent(getScript()..":Crafting:GetItem", function(ItemMake, craftable,
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
stashItems = getStash(stashName)
|
stashItems = getStash(stashName)
|
||||||
for k, v in pairs(craftable[ItemMake] or {}) do
|
for k, v in pairs(craftable[ItemMake]) do
|
||||||
for _, b in pairs(stashItems or {}) do
|
for _, b in pairs(stashItems or {}) do
|
||||||
if k == b.name then
|
if k == b.name then
|
||||||
itemRemove[k] = v
|
itemRemove[k] = v
|
||||||
@@ -539,8 +583,8 @@ RegisterNetEvent(getScript()..":Crafting:GetItem", function(ItemMake, craftable,
|
|||||||
end
|
end
|
||||||
stashRemoveItem(stashItems, stashName, itemRemove)
|
stashRemoveItem(stashItems, stashName, itemRemove)
|
||||||
else
|
else
|
||||||
if craftable then
|
if craftable[ItemMake] then
|
||||||
for k, v in pairs(craftable[ItemMake] or {}) do
|
for k, v in pairs(craftable[ItemMake]) do
|
||||||
removeItem(tostring(k), v, src)
|
removeItem(tostring(k), v, src)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -651,6 +651,29 @@ function lookEnt(entity)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Function to clone tables, to use when referencing tables that need to be hard set
|
||||||
|
function cloneTable(obj, opts, seen)
|
||||||
|
if type(obj) ~= "table" then return obj end
|
||||||
|
seen = seen or {}
|
||||||
|
if seen[obj] then return seen[obj] end
|
||||||
|
|
||||||
|
local copy = {}
|
||||||
|
seen[obj] = copy
|
||||||
|
|
||||||
|
-- Copy entries
|
||||||
|
for k, v in pairs(obj) do
|
||||||
|
local k2 = (opts and opts.copy_keys) and cloneTable(k, opts, seen) or k
|
||||||
|
copy[k2] = cloneTable(v, opts, seen)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Preserve metatable unless told not to
|
||||||
|
if not (opts and opts.strip_meta) then
|
||||||
|
local mt = getmetatable(obj)
|
||||||
|
if mt ~= nil then setmetatable(copy, mt) end
|
||||||
|
end
|
||||||
|
|
||||||
|
return copy
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------
|
-------------------------------------------------------------
|
||||||
-- Material and Prop Functions
|
-- Material and Prop Functions
|
||||||
|
|||||||
@@ -1568,7 +1568,7 @@ RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount,
|
|||||||
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
debugPrint("^6Bridge^7: ^3"..action.."^7["..invName.."] Player("..src..") "..getItemLabel(item).."("..item..") x"..(amount or 1))
|
debugPrint("^6Bridge^7: ^3"..action.."^7[^6"..invName.."^7] Player(^3"..src.."^7) "..getItemLabel(item).."("..item..") x"..(amount or 1))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -1593,7 +1593,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..") "..getItemLabel(item).."("..item..") x"..(amount or 1))
|
debugPrint("^6Bridge^7: ^3"..action.."^7[^6"..invName.."^7] Player(^3"..src.."^7) "..getItemLabel(item).."("..item..") x"..(amount or 1))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -231,7 +231,6 @@ function gtaProgressBar(data)
|
|||||||
while result == nil do Wait(10) end
|
while result == nil do Wait(10) end
|
||||||
inProgress = false
|
inProgress = false
|
||||||
|
|
||||||
print(tostring(result))
|
|
||||||
-- Cleanup animations/tasks
|
-- Cleanup animations/tasks
|
||||||
if data.dict then
|
if data.dict then
|
||||||
stopAnim(data.dict, data.anim, ped)
|
stopAnim(data.dict, data.anim, ped)
|
||||||
@@ -240,7 +239,6 @@ function gtaProgressBar(data)
|
|||||||
ClearPedTasks(ped)
|
ClearPedTasks(ped)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Cleanup
|
-- Cleanup
|
||||||
FreezeEntityPosition(ped, false)
|
FreezeEntityPosition(ped, false)
|
||||||
|
|
||||||
|
|||||||
14
version.txt
14
version.txt
@@ -1,13 +1,7 @@
|
|||||||
2.1.03
|
2.1.05
|
||||||
|
|
||||||
- Fix hunger and thirst math (add instead of set)
|
- Fix "true/false" print from built-in gta progressbars
|
||||||
- Fix cleanup of targets qb-targets on unload
|
- Revert Crafting system to previous style (I was too quick to do this)
|
||||||
- Add support for new jim-shops exploit protection
|
- Fix singleprogress multiplying crafting recipes
|
||||||
- Add full support for esx_society (fixes esx bossmenu errors)
|
|
||||||
- Fix possible issue with qb-core /command registering
|
|
||||||
- Make ox_lib progressbars return false correctly
|
|
||||||
- Fix ox_inv players current weight checks
|
|
||||||
- User alternate function for inventory retreival for CodeM Inv
|
|
||||||
- Rework _loaders.lua tobe more organised/optimizied
|
|
||||||
|
|
||||||
https://github.com/jimathy/jim_bridge/releases/latest
|
https://github.com/jimathy/jim_bridge/releases/latest
|
||||||
Reference in New Issue
Block a user