mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 14:06:02 +01:00
crafting exploit fixes
This has several changes When crafting, it now checks if the inventory is open and stops crafting dead and warns the player with a print. Multicraft now checks if you have space in your inventory for the items and limits the max amount craftable Also fixes the "title" of the qb-input box when crafting Also changed the anim flag for the "placing items" to hopefully keep you in place
This commit is contained in:
@@ -228,20 +228,24 @@ function multiCraft(data)
|
||||
end
|
||||
end
|
||||
|
||||
local dialog = createInput(data.craftable.Header, {
|
||||
local carryMax = triggerCallback(getScript()..":server:getMaxCarryCraft", {
|
||||
item = data.item,
|
||||
max = max
|
||||
})
|
||||
|
||||
local dialog = createInput(data.craftable.Header..(Config.System.Menu == "qb" and ": "..br.."How many to craft? "..br.."Max: "..carryMax or ""), {
|
||||
((Config.System.Menu == "ox") and {
|
||||
type = "slider",
|
||||
label = "How many to craft?",
|
||||
label = "How many to craft? "..br.."Max: "..carryMax,
|
||||
required = true,
|
||||
default = 1,
|
||||
min = 1,
|
||||
max = max
|
||||
max = carryMax
|
||||
}) or nil,
|
||||
((Config.System.Menu == "qb") and {
|
||||
type = "number",
|
||||
label = "How many to craft?"..br.."Max: "..max,
|
||||
name = "amount",
|
||||
isRecuired = true,
|
||||
isRequired = true,
|
||||
default = 1,
|
||||
}) or nil,
|
||||
})
|
||||
@@ -251,18 +255,14 @@ function multiCraft(data)
|
||||
|
||||
end
|
||||
if Config.System.Menu == "qb" then
|
||||
if dialog["amount"] == nil or dialog["amount"] == "" then
|
||||
dialog["amount"] = 1
|
||||
end
|
||||
dialog["amount"] = tonumber(dialog["amount"])
|
||||
if dialog["amount"] > max or dialog["amount"] < 1 or dialog["amount"] == nil or dialog["amount"] == "" then
|
||||
if dialog["amount"] > carryMax or dialog["amount"] < 1 or dialog["amount"] == nil or dialog["amount"] == "" then
|
||||
triggerNotify(nil, "Invalid Amount", "error")
|
||||
craftingMenu(data)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
makeItem({
|
||||
item = data.item,
|
||||
craft = data.craft,
|
||||
@@ -270,7 +270,6 @@ function multiCraft(data)
|
||||
amount = dialog["amount"] or dialog[1],
|
||||
coords = data.coords,
|
||||
stashName = stashName or nil,
|
||||
--stashTable = data.stashName,
|
||||
onBack = data.onBack,
|
||||
metadata = data.metadata,
|
||||
})
|
||||
@@ -327,19 +326,23 @@ function makeItem(data)
|
||||
local crafted, crafting = true, true
|
||||
local cam = createTempCam(PlayerPedId(), data.coords)
|
||||
startTempCam(cam)
|
||||
|
||||
for i = 1, craftAmount do
|
||||
for k, v in pairs(data.craft) do
|
||||
if not excludeKeys[k] then
|
||||
if 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")
|
||||
crafted, crafting = false, false
|
||||
return
|
||||
end
|
||||
if crafting and progressBar({
|
||||
label = "Using "..b.." "..Items[l].label,
|
||||
time = 1000,
|
||||
cancel = true,
|
||||
dict = 'pickup_object',
|
||||
anim = "putdown_low",
|
||||
flag = 48,
|
||||
flag = 49,
|
||||
icon = l,
|
||||
}) then
|
||||
TriggerEvent((isStarted(QBInv) and QBInvNew and "qb-" or "")..'inventory:client:ItemBox', Items[l], "use", b)
|
||||
@@ -349,6 +352,11 @@ function makeItem(data)
|
||||
end
|
||||
Wait(200)
|
||||
end
|
||||
if isInventoryOpen() then
|
||||
print("^1Error^7: ^2Inventory is open, you tried to break things")
|
||||
crafted, crafting = false, false
|
||||
return
|
||||
end
|
||||
if crafted then
|
||||
local craftProp = nil
|
||||
if prop then
|
||||
@@ -359,6 +367,11 @@ function makeItem(data)
|
||||
local s = data.sound
|
||||
PlaySoundFromEntity(s.soundId, s.audioName, PlayerPedId(), s.audioRef, true, 0)
|
||||
end
|
||||
if isInventoryOpen() then
|
||||
print("^1Error^7: ^2Inventory is open, you tried to break things")
|
||||
crafted, crafting = false, false
|
||||
return
|
||||
end
|
||||
if crafting and progressBar({
|
||||
label = bartext..((metadata and metadata.label) or Items[data.item].label),
|
||||
time = bartime,
|
||||
@@ -410,7 +423,6 @@ function makeItem(data)
|
||||
end
|
||||
stopTempCam()
|
||||
CraftLock = false
|
||||
lockInv(false)
|
||||
if canReturn then craftingMenu(data) end
|
||||
ClearPedTasks(PlayerPedId())
|
||||
end
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
function lockInv(toggle)
|
||||
FreezeEntityPosition(PlayerPedId(), toggle)
|
||||
LocalPlayer.state:set("inv_busy", toggle, true)
|
||||
LocalPlayer.state:set("invBusy", toggle, true)
|
||||
TriggerEvent('inventory:client:busy:status', toggle)
|
||||
TriggerEvent('canUseInventoryAndHotbar:toggle', not toggle)
|
||||
end
|
||||
@@ -168,4 +169,39 @@ function getPlayerInv(src)
|
||||
print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3starter^1.^2lua^7")
|
||||
end
|
||||
return grabInv, foundInv
|
||||
end
|
||||
|
||||
|
||||
function isInventoryOpen()
|
||||
if isStarted(OXInv) then
|
||||
return LocalPlayer.state.invBusy
|
||||
|
||||
elseif isStarted(QSInv) then
|
||||
return exports[QSInv]:inInventory()
|
||||
|
||||
elseif isStarted(OrigenInv) then
|
||||
return exports[OrigenInv]:IsInventoryOpen()
|
||||
|
||||
elseif isStarted(CoreInv) then
|
||||
return exports[CoreInv]:isInventoryOpen()
|
||||
|
||||
elseif isStarted(CodeMInv) then
|
||||
return false -- CodeM doesn't have a function to check if the inventory is open
|
||||
|
||||
elseif isStarted(TgiannInv) then
|
||||
return exports["tgiann-inventory"]:IsInventoryActive()
|
||||
|
||||
elseif isStarted(QBInv) then
|
||||
return LocalPlayer.state.inv_busy
|
||||
|
||||
elseif isStarted(PSInv) then
|
||||
return LocalPlayer.state.inv_busy
|
||||
|
||||
elseif ESX and isStarted(ESXExport) then
|
||||
return false
|
||||
|
||||
elseif isStarted(RSGInv) then
|
||||
return LocalPlayer.state.inv_busy
|
||||
|
||||
end
|
||||
end
|
||||
@@ -698,6 +698,26 @@ if isServer() then
|
||||
return result
|
||||
end)
|
||||
|
||||
createCallback(getScript()..":server:getMaxCarryCraft", function(source, data)
|
||||
local src = source
|
||||
local item = data.item
|
||||
local max = data.max or 100
|
||||
|
||||
local maxCanCarry = 0
|
||||
for i = 1, max do
|
||||
local checkTable = {
|
||||
[item] = i
|
||||
}
|
||||
local result = canCarry(checkTable, src)
|
||||
if result[item] == true then
|
||||
maxCanCarry = i
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
return maxCanCarry
|
||||
end)
|
||||
|
||||
local AuthEvent = getScript()..":"..keyGen()..keyGen()..keyGen()..keyGen()..":"..keyGen()..keyGen()..keyGen()..keyGen()
|
||||
validTokens = validTokens or {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user