Merge pull request #4 from jimathy/duty-fixes

Duty fixes + CheckVersion + better debug
This commit is contained in:
Jim Shield
2024-01-18 13:16:45 +00:00
committed by GitHub
4 changed files with 90 additions and 19 deletions

View File

@@ -558,12 +558,24 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
if hasItem(item, amount and amount or 1, src) then -- check if you still have the item
if GetResourceState(OXInv):find("start") then
local success = exports[OXInv]:RemoveItem(src, item, (amount and amount or 1), nil)
if Config.System.Debug then
print("^6Bridge^7: ^1Removing ^2from Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) - '"..OXInv)
end
elseif GetResourceState(QSInv):find("start") then
local success = exports[QSInv]:RemoveItem(src, item, amount)
if Config.System.Debug then
print("^6Bridge^7: ^1Removing ^2from Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) - '"..QSInv)
end
elseif GetResourceState(CoreInv):find("start") then
local success = exports[CoreInv]:removeItemExact('primary-'..src, item, amount)
if Config.System.Debug then
print("^6Bridge^7: ^1Removing ^2from Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) - '"..CoreInv)
end
elseif GetResourceState(CodeMInv):find("start") then
local success = exports[CodeMInv]:RemoveItem(src, item, amount)
if Config.System.Debug then
print("^6Bridge^7: ^1Removing ^2from Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) - '"..CodeMInv)
end
elseif GetResourceState(QBInv):find("start") then
while remamount > 0 do
if Core.Functions.GetPlayer(src).Functions.RemoveItem(item, 1) then end
@@ -572,10 +584,12 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
if Config.Crafting.showItemBox then
TriggerClientEvent('inventory:client:ItemBox', src, Items[item], "remove", (amount and amount or 1))
end
if Config.System.Debug then
print("^6Bridge^7: ^1Removing ^2from Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) - '"..QBInv)
end
else
print("^4Error^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7")
end
if Config.System.Debug then
print("^6Bridge^7: ^1Removing ^2from Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7)'")
end
else
dupeWarn(src, item) -- if not boot the player
end
@@ -584,26 +598,34 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
if GetResourceState(OXInv):find("start") then
local success = exports[OXInv]:AddItem(src, item, amount or 1, nil)
if Config.System.Debug then
print("^6Bridge^7: ^4Giving ^2Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) ^1OX^7'")
print("^6Bridge^7: ^4Giving ^2Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) ^7"..OXInv)
end
elseif GetResourceState(QSInv):find("start") then
local success = exports[QSInv]:AddItem(src, item, amount)
if Config.System.Debug then
print("^6Bridge^7: ^4Giving ^2Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) ^1QS^7'")
print("^6Bridge^7: ^4Giving ^2Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) ^7"..QSInv)
end
elseif GetResourceState(CoreInv):find("start") then
local success = exports[CoreInv]:addItem('primary-'..src, item, amount)
if Config.System.Debug then
print("^6Bridge^7: ^4Giving ^2Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) ^1Core^7'")
print("^6Bridge^7: ^4Giving ^2Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) ^7"..CoreInv)
end
elseif GetResourceState(CodeMInv):find("start") then
local success = exports[CodeMInv]:AddItem(src, item, amount)
elseif GetResourceState(QBInv):find("start") then
if Config.System.Debug then
print("^6Bridge^7: ^4Giving ^2Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) ^7"..CodeMInv)
end
elseif GetResourceState(QBInv):find("start") then
if Core.Functions.GetPlayer(src).Functions.AddItem(item, amount or 1) then
--if Config.Crafting.showItemBox then
TriggerClientEvent("inventory:client:ItemBox", src, Items[item], "add", amount and amount or 1)
--end
end
if Config.System.Debug then
print("^6Bridge^7: ^4Giving ^2Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) ^7"..QBInv)
end
else
print("^4Error^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7")
end
end
end)
@@ -614,12 +636,11 @@ function dupeWarn(src, item)
if Config.System.Debug == false then
DropPlayer(src, src.." ^1Kicked for attempting to duplicate items")
end
print("^5DupeWarn:^7: (^1"..tostring(src).."^7) ^2Dropped from server for item duplicating^7")
print("^5DupeWarn:^7: (^1"..tostring(src).."^7) ^2Dropped from server - exploit protection detected an item not being found in players inventory^7")
end
function toggleDuty()
if GetResourceState(QBExport):find("start") then
if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
TriggerServerEvent("QBCore:ToggleDuty")
else
onDuty = not onDuty
@@ -633,12 +654,21 @@ end
local function CheckVersion()
if IsDuplicityVersion() then
local currentVersion = "^3"..GetResourceMetadata(GetCurrentResourceName(), 'version'):gsub("%.", "^7.^3").."^7"
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/UpdateVersions/master/'..GetCurrentResourceName()..'.txt', function(err, newestVersion, headers)
if not newestVersion then print("Currently unable to run a version check.") return end
local currentVersion = "^3"..GetResourceMetadata(GetCurrentResourceName(), 'version'):gsub("%.", "^7.^3").."^7"
newestVersion = "^3"..newestVersion:sub(1, -2):gsub("%.", "^7.^3").."^7"
print("^6Version Check^7: ^2Running^7: "..currentVersion.." ^2Latest^7: "..newestVersion)
print(newestVersion == currentVersion and '^6You are running the latest version.^7 ('..currentVersion..')' or "^1You are currently running an outdated version^7, ^1please update^7!")
if not newestVersion then
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/'..GetCurrentResourceName()..'/master/version.txt', function(err, freeVersion, headers)
if not freeVersion then print("^1Currently unable to run a version check for ^7'^3"..GetCurrentResourceName().."^7' ("..currentVersion.."^7)") return end
local currentVersion = "^3"..GetResourceMetadata(GetCurrentResourceName(), 'version'):gsub("%.", "^7.^3").."^7"
freeVersion = "^3"..freeVersion:sub(1, -2):gsub("%.", "^7.^3").."^7"
print("^6Version Check^7: ^2Running^7: "..currentVersion.." ^2Latest^7: "..freeVersion)
print(freeVersion == currentVersion and "^7'^3"..GetCurrentResourceName().."^7' - ^6You are running the latest version.^7 ("..currentVersion..")" or "^7'^3"..GetCurrentResourceName().."^7' - ^1You are currently running an outdated version^7, ^1please update^7!")
end)
else
newestVersion = "^3"..newestVersion:sub(1, -2):gsub("%.", "^7.^3").."^7"
print("^6Version Check^7: ^2Running^7: "..currentVersion.." ^2Latest^7: "..newestVersion)
print(newestVersion == currentVersion and '^6You are running the latest version.^7 ('..currentVersion..')' or "^1You are currently running an outdated version^7, ^1please update^7!")
end
end)
end
end
@@ -833,4 +863,4 @@ function StopEffects() -- Used to clear up any effects stuck on screen
AnimpostfxStop('RaceTurbo')
AnimpostfxStop('FocusIn')
AnimpostfxStop('Rampage')
end
end

View File

@@ -1,6 +1,6 @@
name "Jim_Bridge"
author "Jimathy"
version "alpha"
version "1.0"
description "Framework Bridge By Jimathy"
fx_version "cerulean"
game "gta5"

1
version.txt Normal file
View File

@@ -0,0 +1 @@
1.0

View File

@@ -18,11 +18,23 @@ QBMenuExport = Exports and Exports.QBMenuExport or ""
QBTargetExport = Exports and Exports.QBTargetExport or ""
OXTargetExport = Exports and Exports.OXTargetExport or ""
function CheckBridgeVersion()
if IsDuplicityVersion() then
local currentVersion = "^3"..GetResourceMetadata("jim_bridge", 'version'):gsub("%.", "^7.^3").."^7"
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/jim_bridge/duty-fixes/version.txt', function(err, newestVersion, headers)
if not newestVersion then print("^1Currently unable to run a version check for ^7'^3jim_bridge^7' ("..currentVersion.."^7)") return end
newestVersion = "^3"..newestVersion:sub(1, -2):gsub("%.", "^7.^3").."^7"
print(newestVersion == currentVersion and "^7'^3jim_bridge^7' - ^6You are running the latest version.^7 ("..currentVersion..")" or "^7'^3jim_bridge^7' - ^1You are currently running an outdated version^7, ^1please update^7!")
end)
end
end
CheckBridgeVersion()
for k, v in pairs(Exports) do
if GetResourceState(v):find("start") then print("^6Bridge^7: '^3"..v.."^7' ^2export found ^7") end
end
-- Load item lists from qb-core or ox_lib
-- Load item lists
if GetResourceState(OXInv):find("start") then
print("^6Bridge^7: ^2Loading ^3Items^2 from ^7"..OXInv)
Items = exports[OXInv]:Items()
@@ -42,6 +54,8 @@ elseif GetResourceState(ESXExport):find("start") then
print("^6Bridge^7: ^2Loading ^3Items^2 from ^7"..ESXExport)
ESX = exports[ESXExport]:getSharedObject()
Items = ESX.Items
else
print("^4ERROR^7: ^2No Core Items detected ^7- ^2Check ^3exports^1.^2lua^7")
end
-- Load Vehicles
@@ -79,6 +93,8 @@ elseif GetResourceState(ESXExport):find("start") then
end
end
end)
else
print("^4ERROR^7: ^2No Vehicle info detected ^7- ^2Check ^3exports^1.^2lua^7")
end
-- Load Jobs
@@ -137,6 +153,8 @@ elseif GetResourceState(ESXExport):find("start") then
Gangs = Jobs
end
end)
else
print("^4ERROR^7: ^2No Job/Gang ifo detected ^7- ^2Check ^3exports^1.^2lua^7")
end
function makeBossRoles(role)
@@ -179,6 +197,8 @@ function createPoly(data) local Location = nil
data.onExit()
end
end)
else
print("^4ERROR^7: ^2No PolyZone creation script detected ^7- ^2Check ^3exports^1.^2lua^7")
end
end
@@ -196,6 +216,8 @@ function createCirclePoly(data) local Location = nil
data.onExit()
end
end)
else
print("^4ERROR^7: ^2No PolyZone creation script detected ^7- ^2Check ^3exports^1.^2lua^7")
end
end
@@ -713,9 +735,12 @@ function onPlayerLoaded(func)
elseif GetResourceState(OXCoreExport):find("start") then
if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3onPlayerLoaded^2 with ^7"..OXLibExport) end
AddEventHandler('ox:playerLoaded', func)
else
print("^4ERROR^7: ^2No Core detected for onPlayerLoaded ^7- ^2Check ^3exports^1.^2lua^7")
end
end
-- INPUT --
function createInput(title, opts)
local dialog = nil
@@ -929,19 +954,24 @@ RegisterNetEvent(GetCurrentResourceName()..":server:ChargePlayer", function(cost
if type == "cash" then
if GetResourceState(OXInv):find("start") then
exports[OXInv]:RemoveItem(src, "money", cost)
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, OXInv) end
elseif GetResourceState(QBExport):find("start") then
Core.Functions.GetPlayer(src).Functions.RemoveMoney("cash", cost)
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, QBExport) end
elseif GetResourceState(ESXExport):find("start") then
local Player = ESX.GetPlayerFromId(src)
Player.removeMoney(cost, "")
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, ESXExport) end
end
end
if type == "bank" then
if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
Core.Functions.GetPlayer(src).Functions.RemoveMoney("bank", cost)
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, QBExport) end
elseif GetResourceState(ESXExport):find("start") then
local Player = ESX.GetPlayerFromId(src)
Player.removeMoney(cost, "")
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, ESXExport) end
end
end
end)
@@ -1008,6 +1038,8 @@ function hasJob(job, source, grade) local hasJob = false
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
end
end
else
print("^4ERROR^7: ^2No Core detected for hasJob ^7- ^2Check ^3exports^1.^2lua^7")
end
else
if GetResourceState(ESXExport):find("start") then
@@ -1033,7 +1065,7 @@ function hasJob(job, source, grade) local hasJob = false
if ganginfo.name == job then hasJob = true
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
end
elseif GetResourceState(QBXExport):find("start") and not GetResourceState(QBXExport):find("start") then
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
local info = nil
Core.Functions.GetPlayerData(function(PlayerData)
info = PlayerData
@@ -1048,6 +1080,8 @@ function hasJob(job, source, grade) local hasJob = false
hasJob = true
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
end
else
print("^4ERROR^7: ^2No Core detected for hasJob() ^7- ^2Check ^3exports^1.^2lua^7")
end
end
return hasJob
@@ -1098,6 +1132,8 @@ function getPlayer(source) local Player = {}
bank = info.money["bank"],
}
end
else
print("^4ERROR^7: ^2No Core detected for getPlayer() ^7- ^2Check ^3exports^1.^2lua^7")
end
else
if GetResourceState(ESXExport):find("start") and ESX ~= nil then
@@ -1134,6 +1170,8 @@ function getPlayer(source) local Player = {}
cash = info.money["cash"],
bank = info.money["bank"],
}
else
print("^4ERROR^7: ^2No Core detected for hasJob ^7- ^2Check ^3exports^1.^2lua^7")
end
end
return Player
@@ -1160,6 +1198,8 @@ function invImg(item)
imgLink = "nui://"..CoreInv.."/html/img/"..(Items[item].image or "")
elseif GetResourceState(QBInv and QBInv or ""):find("start") then
imgLink = "nui://"..QBInv.."/html/images/"..(Items[item].image or "")
else
print("^4ERROR^7: ^2No Inventory detected for invImg ^7- ^2Check ^3exports^1.^2lua^7")
end
end
return imgLink