mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-19 06:46:04 +01:00
Tidy up and organise several debugPrints better
This commit is contained in:
@@ -39,7 +39,7 @@ function createCallback(callbackName, funct)
|
|||||||
elseif isStarted(ESXExport) then
|
elseif isStarted(ESXExport) then
|
||||||
ESX.RegisterServerCallback(callbackName, adaptedFunction)
|
ESX.RegisterServerCallback(callbackName, adaptedFunction)
|
||||||
else
|
else
|
||||||
print("^6Bridge^7: ^1ERROR^7: ^3Can't find any script to register callback with", callbackName)
|
print("^1ERROR^7: ^1Can't find any supported framework to register callback with^7: "..callbackName)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ function makeItem(data)
|
|||||||
currentToken = nil -- clear client cached token
|
currentToken = nil -- clear client cached token
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
if data.craft["hasCrafted"] ~= nil then
|
if data.craft["hasCrafted"] ~= nil then
|
||||||
debugPrint("hasCrafted Found, marking '"..data.item.."' as crafted for player")
|
debugPrint("^5Bridge^7: ^3hasCrafted ^2Found^7, ^2marking ^7'^4"..data.item.."^7' ^2as crafted for player^7")
|
||||||
data.craftable.craftedItems[data.item] = true
|
data.craftable.craftedItems[data.item] = true
|
||||||
triggerCallback(getScript()..":server:SetMetadata", "craftedItems", data.craftable.craftedItems)
|
triggerCallback(getScript()..":server:SetMetadata", "craftedItems", data.craftable.craftedItems)
|
||||||
end
|
end
|
||||||
@@ -408,7 +408,7 @@ function makeItem(data)
|
|||||||
if data.craft["exp"] ~= nil then
|
if data.craft["exp"] ~= nil then
|
||||||
craftingLevel += data.craft["exp"].give
|
craftingLevel += data.craft["exp"].give
|
||||||
jsonPrint(data.craft["exp"])
|
jsonPrint(data.craft["exp"])
|
||||||
debugPrint("exp found, giving exp for '"..data.item.."'")
|
debugPrint("^6Bridge^7: ^3EXP ^2found^7, ^2giving exp for ^7'^4"..data.item.."^7'")
|
||||||
triggerCallback(getScript()..":server:SetMetadata", "craftingLevel", craftingLevel)
|
triggerCallback(getScript()..":server:SetMetadata", "craftingLevel", craftingLevel)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -457,9 +457,9 @@ end
|
|||||||
--- @usage
|
--- @usage
|
||||||
RegisterNetEvent(getScript()..":Crafting:GetItem", function(ItemMake, craftable, stashName, metadata, token)
|
RegisterNetEvent(getScript()..":Crafting:GetItem", function(ItemMake, craftable, stashName, metadata, token)
|
||||||
local src = source
|
local src = source
|
||||||
debugPrint(GetInvokingResource())
|
debugPrint("^6Bridge^7: ^4"..getScript().."^7:^4Crafting^7:^4GetItem ^2invoked by^7: "..GetInvokingResource())
|
||||||
if GetInvokingResource() and GetInvokingResource() ~= getScript() and GetInvokingResource() ~= "qb-core" then
|
if GetInvokingResource() and GetInvokingResource() ~= getScript() and GetInvokingResource() ~= "qb-core" then
|
||||||
debugPrint("^1Error^7: ^1Possible exploit^7, ^1vital function was called from an external resource^7")
|
debugPrint("^1ERROR^7: ^1Possible exploit^7, ^1vital function was called from an external resource^7")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -30,25 +30,34 @@ validTokens = {}
|
|||||||
--- end)
|
--- end)
|
||||||
--- ```
|
--- ```
|
||||||
function createUseableItem(item, funct)
|
function createUseableItem(item, funct)
|
||||||
|
if doesItemExist(item) then
|
||||||
|
local itemResource = ""
|
||||||
if isStarted(ESXExport) then
|
if isStarted(ESXExport) then
|
||||||
debugPrint("^6Bridge^7: ^2Registering item as ^3Usable^2 with ^7es_extended^7", item)
|
itemResource = ESXExport
|
||||||
while not ESX do Wait(0) end
|
while not ESX do Wait(0) end
|
||||||
ESX.RegisterUsableItem(item, funct)
|
ESX.RegisterUsableItem(item, funct)
|
||||||
|
|
||||||
elseif isStarted(QBExport) and not isStarted(QBXExport) then
|
elseif isStarted(QBExport) and not isStarted(QBXExport) then
|
||||||
debugPrint("^6Bridge^7: ^2Registering item as ^3Usable^2 with ^7qb-core^7", item)
|
itemResource = QBExport
|
||||||
Core.Functions.CreateUseableItem(item, funct)
|
Core.Functions.CreateUseableItem(item, funct)
|
||||||
|
|
||||||
elseif isStarted(QBXExport) then
|
elseif isStarted(QBXExport) then
|
||||||
debugPrint("^6Bridge^7: ^2Registering item as ^3Usable^2 with ^7qbx_core^7", item)
|
itemResource = QBXExport
|
||||||
exports[QBXExport]:CreateUseableItem(item, funct)
|
exports[QBXExport]:CreateUseableItem(item, funct)
|
||||||
|
|
||||||
elseif isStarted(RSGExport) then
|
elseif isStarted(RSGExport) then
|
||||||
debugPrint("^6Bridge^7: ^2Registering item as ^3Usable^2 with ^1rsg-core^7", item)
|
itemResource = RSGExport
|
||||||
Core.Functions.CreateUseableItem(item, funct)
|
Core.Functions.CreateUseableItem(item, funct)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
if itemResource ~= "" then
|
||||||
|
debugPrint("^6Bridge^7: ^2Registering ^3UsableItem^2 with ^4"..itemResource.."^7:", item)
|
||||||
else
|
else
|
||||||
print("^4ERROR^7: No supported framework detected for registering usable item: ^3"..item.."^7")
|
debugPrint("^4ERROR^7: No supported framework detected for registering usable item: ^3"..item.."^7")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
print("^1ERROR^7: ^1Tried to make item usable but it didn't exist^7: "..item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ end
|
|||||||
--- ```
|
--- ```
|
||||||
function playAnim(animDict, animName, duration, flag, ped, speed)
|
function playAnim(animDict, animName, duration, flag, ped, speed)
|
||||||
loadAnimDict(animDict)
|
loadAnimDict(animDict)
|
||||||
debugPrint("Attempting to make player play anim", animDict, animName)
|
debugPrint("^6Bridge^7: ^3playAnim^7() ^2Triggered^7: ", animDict, animName)
|
||||||
TaskPlayAnim(ped and ped or PlayerPedId(), animDict, animName, speed or 8.0, speed or -8.0, duration or 30000, flag or 50, 1, false, false, false)
|
TaskPlayAnim(ped and ped or PlayerPedId(), animDict, animName, speed or 8.0, speed or -8.0, duration or 30000, flag or 50, 1, false, false, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ end
|
|||||||
--- stopAnim('amb@world_human_hang_out_street@male_c@base', 'base', PlayerPedId())
|
--- stopAnim('amb@world_human_hang_out_street@male_c@base', 'base', PlayerPedId())
|
||||||
--- ```
|
--- ```
|
||||||
function stopAnim(animDict, animName, ped)
|
function stopAnim(animDict, animName, ped)
|
||||||
debugPrint("Stopping anim for "..(ped or PlayerPedId()))
|
debugPrint("^6Bridge^7: ^3stopAnim^7() ^2Triggered^7: ", animDict, animName)
|
||||||
StopAnimTask(ped or PlayerPedId(), animDict, animName, 0.5)
|
StopAnimTask(ped or PlayerPedId(), animDict, animName, 0.5)
|
||||||
StopAnimTask(ped or PlayerPedId(), animName, animDict, 0.5)
|
StopAnimTask(ped or PlayerPedId(), animName, animDict, 0.5)
|
||||||
unloadAnimDict(animDict)
|
unloadAnimDict(animDict)
|
||||||
|
|||||||
@@ -54,14 +54,14 @@ function makeDistVehicle(data, radius, onEnter, onExit)
|
|||||||
onEnter = function()
|
onEnter = function()
|
||||||
vehicle = makeVeh(data.model, data.coords)
|
vehicle = makeVeh(data.model, data.coords)
|
||||||
if onEnter then
|
if onEnter then
|
||||||
debugPrint("makeDistVehicle onEnter running")
|
debugPrint("^6Bridge^7: ^4makeDistVehicle ^3onEnter^7() ^2running^7")
|
||||||
onEnter(vehicle)
|
onEnter(vehicle)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
onExit = function()
|
onExit = function()
|
||||||
deleteVehicle(vehicle)
|
deleteVehicle(vehicle)
|
||||||
if onExit then
|
if onExit then
|
||||||
debugPrint("makeDistVehicle onExit running")
|
debugPrint("^6Bridge^7: ^4makeDistVehicle ^3onExit^7() ^2running^7")
|
||||||
onExit(vehicle)
|
onExit(vehicle)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -221,8 +221,9 @@ end)
|
|||||||
--- registerShop("weaponShop", "Weapon Shop", weaponItems, "society_weapons")
|
--- registerShop("weaponShop", "Weapon Shop", weaponItems, "society_weapons")
|
||||||
--- ```
|
--- ```
|
||||||
function registerShop(name, label, items, society)
|
function registerShop(name, label, items, society)
|
||||||
|
local shopResource = ""
|
||||||
if isStarted(OXInv) then
|
if isStarted(OXInv) then
|
||||||
debugPrint("^6Bridge^7: ^2Registering ^3OX ^2Store^7:", name, label)
|
shopResource = OXInv
|
||||||
exports[OXInv]:RegisterShop(name, {
|
exports[OXInv]:RegisterShop(name, {
|
||||||
name = label,
|
name = label,
|
||||||
inventory = items,
|
inventory = items,
|
||||||
@@ -230,11 +231,11 @@ function registerShop(name, label, items, society)
|
|||||||
})
|
})
|
||||||
|
|
||||||
elseif isStarted(TgiannInv) then
|
elseif isStarted(TgiannInv) then
|
||||||
debugPrint("^6Bridge^7: ^2Registering ^3Tgiann ^2Store^7:", name, label)
|
shopResource = TgiannInv
|
||||||
exports[TgiannInv]:RegisterShop(name, items)
|
exports[TgiannInv]:RegisterShop(name, items)
|
||||||
|
|
||||||
elseif isStarted(QBInv) and QBInvNew then
|
elseif isStarted(QBInv) and checkExportExists(QBInv, "CreateShop") then
|
||||||
debugPrint("^6Bridge^7: ^2Registering ^3QB ^2Store^7:", name, label)
|
shopResource = QBInv
|
||||||
exports[QBInv]:CreateShop({
|
exports[QBInv]:CreateShop({
|
||||||
name = name,
|
name = name,
|
||||||
label = label,
|
label = label,
|
||||||
@@ -244,7 +245,7 @@ function registerShop(name, label, items, society)
|
|||||||
})
|
})
|
||||||
|
|
||||||
elseif isStarted(PSInv) and QBInvNew then
|
elseif isStarted(PSInv) and QBInvNew then
|
||||||
debugPrint("^6Bridge^7: ^2Registering ^3PS ^2Store^7:", name, label)
|
shopResource = PSInv
|
||||||
exports[PSInv]:CreateShop({
|
exports[PSInv]:CreateShop({
|
||||||
name = name,
|
name = name,
|
||||||
label = label,
|
label = label,
|
||||||
@@ -254,7 +255,7 @@ function registerShop(name, label, items, society)
|
|||||||
})
|
})
|
||||||
|
|
||||||
elseif isStarted(RSGInv) then
|
elseif isStarted(RSGInv) then
|
||||||
debugPrint("^6Bridge^7: ^2Registering ^3RSG ^2Store^7:", name, label)
|
shopResource = RSGInv
|
||||||
exports[RSGInv]:CreateShop({
|
exports[RSGInv]:CreateShop({
|
||||||
name = name,
|
name = name,
|
||||||
label = label,
|
label = label,
|
||||||
@@ -263,4 +264,9 @@ function registerShop(name, label, items, society)
|
|||||||
society = society,
|
society = society,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
if shopResource ~= "" then
|
||||||
|
debugPrint("^6Bridge^7: ^2Registering ^5"..shopResource.." ^3Store^7:", name, "^4Label^7: "..label)
|
||||||
|
else
|
||||||
|
debugPrint("^1ERROR^7: ^1Couldn't find supported inventory to register command^7:", name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -644,27 +644,25 @@ end
|
|||||||
--- )
|
--- )
|
||||||
--- ```
|
--- ```
|
||||||
function registerStash(name, label, slots, weight, owner, coords)
|
function registerStash(name, label, slots, weight, owner, coords)
|
||||||
|
local stashResource = ""
|
||||||
if isStarted(OXInv) then
|
if isStarted(OXInv) then
|
||||||
debugPrint("^6Bridge^7: ^2Registering ^3OX ^2Stash^7:", name, label, owner or nil)
|
stashResource = OXInv
|
||||||
exports[OXInv]:RegisterStash(name, label, slots or 50, weight or 4000000, owner or nil)
|
exports[OXInv]:RegisterStash(name, label, slots or 50, weight or 4000000, owner or nil)
|
||||||
|
|
||||||
--elseif isStarted(QSInv) then
|
|
||||||
-- debugPrint("^6Bridge^7: ^2Registering ^3QS ^2Stash^7:", name, label)
|
|
||||||
-- exports[QSInv]:RegisterStash(name, label, slots or 50, weight or 4000000)
|
|
||||||
|
|
||||||
--elseif isStarted(CoreInv) then
|
|
||||||
-- debugPrint("^6Bridge^7: ^2Registering ^3CoreInv ^2Stash^7:", name, label)
|
|
||||||
-- exports[CoreInv]:openHolder(nil, name, 'stash', nil, nil, false, nil)
|
|
||||||
|
|
||||||
elseif isStarted(OrigenInv) then
|
elseif isStarted(OrigenInv) then
|
||||||
debugPrint("^6Bridge^7: ^2Registering ^3OrigenInv ^2Stash^7:", name, label)
|
stashResource = OrigenInv
|
||||||
exports["origen_inventory"]:registerStash(name, label, slots or 50, weight or 4000000)
|
exports["origen_inventory"]:registerStash(name, label, slots or 50, weight or 4000000)
|
||||||
|
|
||||||
elseif isStarted(TgiannInv) then
|
elseif isStarted(TgiannInv) then
|
||||||
debugPrint("^6Bridge^7: ^2Registering ^3TgiannInv ^2Stash^7:", name, label)
|
stashResource = TgiannInv
|
||||||
exports[TgiannInv]:RegisterStash(name, label, slots or 50, weight or 4000000)
|
exports[TgiannInv]:RegisterStash(name, label, slots or 50, weight or 4000000)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
if stashResource ~= "" then
|
||||||
|
debugPrint("^6Bridge^7: ^2Registering ^4"..stashResource.." ^3Stash^7:", name, "^4Label^7: "..label)
|
||||||
|
else
|
||||||
|
print("^1ERROR^7: ^1Couldn't find supported inventory to register stash^7:", name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if isServer() then
|
if isServer() then
|
||||||
|
|||||||
@@ -21,24 +21,29 @@
|
|||||||
--- })
|
--- })
|
||||||
--- ```
|
--- ```
|
||||||
function registerCommand(command, options)
|
function registerCommand(command, options)
|
||||||
|
local commandResource = ""
|
||||||
if isStarted(OXLibExport) then
|
if isStarted(OXLibExport) then
|
||||||
debugPrint("^6Bridge^7: ^2Registering ^3Command^2 with ^7"..OXLibExport, command)
|
commandResource = OXLibExport
|
||||||
lib.addCommand(command, { help = options[1], restricted = options[5] and "group."..options[5] or nil }, options[4])
|
lib.addCommand(command, { help = options[1], restricted = options[5] and "group."..options[5] or nil }, options[4])
|
||||||
|
|
||||||
elseif isStarted(QBExport) and not isStarted(QBXExport) then
|
elseif isStarted(QBExport) and not isStarted(QBXExport) then
|
||||||
debugPrint("^6Bridge^7: ^2Registering ^3Command^2 with ^7"..QBExport, command)
|
commandResource = QBExport
|
||||||
Core.Commands.Add(command, options[1], options[2], options[3], options[4], options[5] or nil)
|
Core.Commands.Add(command, options[1], options[2], options[3], options[4], options[5] or nil)
|
||||||
|
|
||||||
elseif isStarted(RSGExport) then
|
elseif isStarted(RSGExport) then
|
||||||
debugPrint("^6Bridge^7: ^2Registering ^3Command^2 with ^7"..RSGExport, command)
|
commandResource = RSGExport
|
||||||
Core.Commands.Add(command, options[1], options[2], options[3], options[4], options[5] or nil)
|
Core.Commands.Add(command, options[1], options[2], options[3], options[4], options[5] or nil)
|
||||||
|
|
||||||
elseif isStarted(ESXExport) then
|
elseif isStarted(ESXExport) then
|
||||||
debugPrint("^6Bridge^7: ^2Registering ^3Command^2 with ^7ESX Legacy", command)
|
commandResource = ESXExport
|
||||||
ESX.RegisterCommand(command, options[5] or 'admin', function(xPlayer, args, showError)
|
ESX.RegisterCommand(command, options[5] or 'admin', function(xPlayer, args, showError)
|
||||||
options[4](xPlayer.source, args, showError)
|
options[4](xPlayer.source, args, showError)
|
||||||
end, false, { help = options[1] })
|
end, false, { help = options[1] })
|
||||||
|
|
||||||
end
|
end
|
||||||
|
if commandResource ~= "" then
|
||||||
|
debugPrint("^6Bridge^7: ^2Registering ^3Command^2 with ^4"..commandResource.."^7:", "^7/"..command)
|
||||||
|
else
|
||||||
|
print("^1ERROR^7: ^1Couldn't find supported framework to register command^7:", "/"..command)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user