mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e801910519 | ||
|
|
dbca627bc3 | ||
|
|
b09534aad5 | ||
|
|
52dc9ff8ae | ||
|
|
10e184afb0 | ||
|
|
4e645001fb | ||
|
|
e33b68bd55 | ||
|
|
7094bda2fb | ||
|
|
409c181cb2 | ||
|
|
6c38f90b9a | ||
|
|
d693a99852 | ||
|
|
508c4a734a | ||
|
|
cd93ea3a38 |
21
README.md
21
README.md
@@ -24,3 +24,24 @@ The installation of this script is simple
|
|||||||
- it just needs to start before any script that requires it
|
- it just needs to start before any script that requires it
|
||||||
- it can start before core scripts if you want
|
- it can start before core scripts if you want
|
||||||
- for `qb-core` I personally place this script in `resources > [standalone]`
|
- for `qb-core` I personally place this script in `resources > [standalone]`
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Support for different exports and scripts
|
||||||
|
|
||||||
|
In exports.lua is the list of script folder names
|
||||||
|
|
||||||
|
This is for people who have customised/renamed scripts
|
||||||
|
|
||||||
|
eg. for people who use `ps-inventory`, this is mainly based on qb-inventory
|
||||||
|
so you need to rename
|
||||||
|
```lua
|
||||||
|
QBInv = "qb-inventory",
|
||||||
|
```
|
||||||
|
to
|
||||||
|
```lua
|
||||||
|
QBInv = "ps-inventory",
|
||||||
|
```
|
||||||
|
|
||||||
|
This will now use events from `ps-inventory` and use it through out the scripts.
|
||||||
10
crafting.lua
10
crafting.lua
@@ -28,7 +28,7 @@ function GetStashTimeout(stashName, stop)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local CraftLock = false
|
local CraftLock = false
|
||||||
function craftingMenu(data)
|
function craftingMenu(data) local hasjob = false
|
||||||
if CraftLock then return end
|
if CraftLock then return end
|
||||||
if data.stashName and not GetStashTimeout(data.stashName) then
|
if data.stashName and not GetStashTimeout(data.stashName) then
|
||||||
--triggerNotify(nil, "Chacking", "success")
|
--triggerNotify(nil, "Chacking", "success")
|
||||||
@@ -40,12 +40,12 @@ function craftingMenu(data)
|
|||||||
for k, v in pairs(Recipes[i]) do
|
for k, v in pairs(Recipes[i]) do
|
||||||
if k ~= "amount" and k ~= "job" and k ~= "gang" then
|
if k ~= "amount" and k ~= "job" and k ~= "gang" then
|
||||||
if Recipes[i].job then hasjob = false
|
if Recipes[i].job then hasjob = false
|
||||||
for l, b in pairs(data.craftable[i]["job"]) do
|
for l, b in pairs(Recipes[i].job) do
|
||||||
hasjob = hasJob(l)
|
hasjob = hasJob(l, nil, b)
|
||||||
|
if hasJob == true then break end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local setheader, settext = "", ""
|
local setheader, settext = "", ""
|
||||||
local text = ""
|
|
||||||
local disable = false
|
local disable = false
|
||||||
local checktable = {}
|
local checktable = {}
|
||||||
if Recipes[i].job and hasjob == false then else
|
if Recipes[i].job and hasjob == false then else
|
||||||
@@ -308,7 +308,7 @@ function hasItem(items, amount, src) local amount, count = amount and amount or
|
|||||||
else if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end return false end
|
else if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end return false end
|
||||||
|
|
||||||
elseif GetResourceState(QSInv):find("start") then
|
elseif GetResourceState(QSInv):find("start") then
|
||||||
for _, itemData in pairs(exports[QSInv]:GetInventory()) do
|
for _, itemData in pairs(exports[QSInv]:getUserInventory()) do
|
||||||
if itemData and (itemData.name == items) then
|
if itemData and (itemData.name == items) then
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2Item^7: '^3"..tostring(items).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)") end
|
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2Item^7: '^3"..tostring(items).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)") end
|
||||||
count += (itemData.amount or 1)
|
count += (itemData.amount or 1)
|
||||||
|
|||||||
@@ -95,11 +95,26 @@ function makeProp(data, freeze, synced)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function cv(amount)
|
function cv(amount)
|
||||||
local formatted = amount
|
local formatted = amount or "0"
|
||||||
while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if (k==0) then break end Wait(0) end
|
while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if (k==0) then break end Wait(0) end
|
||||||
return formatted
|
return formatted
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function DrawText3D(x, y, z, text)
|
||||||
|
SetTextScale(0.35, 0.35)
|
||||||
|
SetTextFont(4)
|
||||||
|
SetTextProportional(true)
|
||||||
|
SetTextColour(255, 255, 255, 215)
|
||||||
|
BeginTextCommandDisplayText("STRING")
|
||||||
|
SetTextCentre(true)
|
||||||
|
AddTextComponentSubstringPlayerName(text)
|
||||||
|
SetDrawOrigin(x,y,z, 0)
|
||||||
|
EndTextCommandDisplayText(0.0, 0.0)
|
||||||
|
local factor = string.len(text) / 370
|
||||||
|
DrawRect(0.0, 0.0 + 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75)
|
||||||
|
ClearDrawOrigin()
|
||||||
|
end
|
||||||
|
|
||||||
AddEventHandler('onResourceStop', function(r)
|
AddEventHandler('onResourceStop', function(r)
|
||||||
if r ~= GetCurrentResourceName() then return end
|
if r ~= GetCurrentResourceName() then return end
|
||||||
stopSpinner()
|
stopSpinner()
|
||||||
@@ -288,8 +303,6 @@ function progressBar(data)
|
|||||||
if data.cam then stopTempCam(data.cam) end
|
if data.cam then stopTempCam(data.cam) end
|
||||||
end
|
end
|
||||||
|
|
||||||
exports["esx_progressbar"]:Progressbar(message, length, Options)
|
|
||||||
|
|
||||||
elseif Config.System.ProgressBar == "qb" then
|
elseif Config.System.ProgressBar == "qb" then
|
||||||
Core.Functions.Progressbar("mechbar",
|
Core.Functions.Progressbar("mechbar",
|
||||||
data.label,
|
data.label,
|
||||||
@@ -545,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 hasItem(item, amount and amount or 1, src) then -- check if you still have the item
|
||||||
if GetResourceState(OXInv):find("start") then
|
if GetResourceState(OXInv):find("start") then
|
||||||
local success = exports[OXInv]:RemoveItem(src, item, (amount and amount or 1), nil)
|
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
|
elseif GetResourceState(QSInv):find("start") then
|
||||||
local success = exports[QSInv]:RemoveItem(src, item, amount)
|
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
|
elseif GetResourceState(CoreInv):find("start") then
|
||||||
local success = exports[CoreInv]:removeItemExact('primary-'..src, item, amount)
|
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
|
elseif GetResourceState(CodeMInv):find("start") then
|
||||||
local success = exports[CodeMInv]:RemoveItem(src, item, amount)
|
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
|
elseif GetResourceState(QBInv):find("start") then
|
||||||
while remamount > 0 do
|
while remamount > 0 do
|
||||||
if Core.Functions.GetPlayer(src).Functions.RemoveItem(item, 1) then end
|
if Core.Functions.GetPlayer(src).Functions.RemoveItem(item, 1) then end
|
||||||
@@ -558,10 +583,12 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
|
|||||||
end
|
end
|
||||||
if Config.Crafting.showItemBox then
|
if Config.Crafting.showItemBox then
|
||||||
TriggerClientEvent('inventory:client:ItemBox', src, Items[item], "remove", (amount and amount or 1))
|
TriggerClientEvent('inventory:client:ItemBox', src, Items[item], "remove", (amount and amount or 1))
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if Config.System.Debug then
|
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)'")
|
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
|
end
|
||||||
else
|
else
|
||||||
dupeWarn(src, item) -- if not boot the player
|
dupeWarn(src, item) -- if not boot the player
|
||||||
@@ -571,26 +598,34 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
|
|||||||
if GetResourceState(OXInv):find("start") then
|
if GetResourceState(OXInv):find("start") then
|
||||||
local success = exports[OXInv]:AddItem(src, item, amount or 1, nil)
|
local success = exports[OXInv]:AddItem(src, item, amount or 1, nil)
|
||||||
if Config.System.Debug 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) ^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
|
end
|
||||||
elseif GetResourceState(QSInv):find("start") then
|
elseif GetResourceState(QSInv):find("start") then
|
||||||
local success = exports[QSInv]:AddItem(src, item, amount)
|
local success = exports[QSInv]:AddItem(src, item, amount)
|
||||||
if Config.System.Debug 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) ^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
|
end
|
||||||
elseif GetResourceState(CoreInv):find("start") then
|
elseif GetResourceState(CoreInv):find("start") then
|
||||||
local success = exports[CoreInv]:addItem('primary-'..src, item, amount)
|
local success = exports[CoreInv]:addItem('primary-'..src, item, amount)
|
||||||
if Config.System.Debug 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) ^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
|
end
|
||||||
elseif GetResourceState(CodeMInv):find("start") then
|
elseif GetResourceState(CodeMInv):find("start") then
|
||||||
local success = exports[CodeMInv]:AddItem(src, item, amount)
|
local success = exports[CodeMInv]: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) ^7"..CodeMInv)
|
||||||
|
end
|
||||||
elseif GetResourceState(QBInv):find("start") then
|
elseif GetResourceState(QBInv):find("start") then
|
||||||
if Core.Functions.GetPlayer(src).Functions.AddItem(item, amount or 1) then
|
if Core.Functions.GetPlayer(src).Functions.AddItem(item, amount or 1) then
|
||||||
--if Config.Crafting.showItemBox then
|
--if Config.Crafting.showItemBox then
|
||||||
TriggerClientEvent("inventory:client:ItemBox", src, Items[item], "add", amount and amount or 1)
|
TriggerClientEvent("inventory:client:ItemBox", src, Items[item], "add", amount and amount or 1)
|
||||||
--end
|
--end
|
||||||
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
|
end
|
||||||
end)
|
end)
|
||||||
@@ -601,12 +636,11 @@ function dupeWarn(src, item)
|
|||||||
if Config.System.Debug == false then
|
if Config.System.Debug == false then
|
||||||
DropPlayer(src, src.." ^1Kicked for attempting to duplicate items")
|
DropPlayer(src, src.." ^1Kicked for attempting to duplicate items")
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
function toggleDuty()
|
function toggleDuty()
|
||||||
if GetResourceState(QBExport):find("start") then
|
if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
||||||
TriggerServerEvent("QBCore:ToggleDuty")
|
TriggerServerEvent("QBCore:ToggleDuty")
|
||||||
else
|
else
|
||||||
onDuty = not onDuty
|
onDuty = not onDuty
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name "Jim_Bridge"
|
name "Jim_Bridge"
|
||||||
author "Jimathy"
|
author "Jimathy"
|
||||||
version "alpha"
|
version "1.0"
|
||||||
description "Framework Bridge By Jimathy"
|
description "Framework Bridge By Jimathy"
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
|
|||||||
1
version.txt
Normal file
1
version.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
1.0
|
||||||
211
wrapper.lua
211
wrapper.lua
@@ -18,11 +18,23 @@ QBMenuExport = Exports and Exports.QBMenuExport or ""
|
|||||||
QBTargetExport = Exports and Exports.QBTargetExport or ""
|
QBTargetExport = Exports and Exports.QBTargetExport or ""
|
||||||
OXTargetExport = Exports and Exports.OXTargetExport 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
|
for k, v in pairs(Exports) do
|
||||||
if GetResourceState(v):find("start") then print("^6Bridge^7: '^3"..v.."^7' ^2export found ^7") end
|
if GetResourceState(v):find("start") then print("^6Bridge^7: '^3"..v.."^7' ^2export found ^7") end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Load item lists from qb-core or ox_lib
|
-- Load item lists
|
||||||
if GetResourceState(OXInv):find("start") then
|
if GetResourceState(OXInv):find("start") then
|
||||||
print("^6Bridge^7: ^2Loading ^3Items^2 from ^7"..OXInv)
|
print("^6Bridge^7: ^2Loading ^3Items^2 from ^7"..OXInv)
|
||||||
Items = exports[OXInv]:Items()
|
Items = exports[OXInv]:Items()
|
||||||
@@ -42,6 +54,8 @@ elseif GetResourceState(ESXExport):find("start") then
|
|||||||
print("^6Bridge^7: ^2Loading ^3Items^2 from ^7"..ESXExport)
|
print("^6Bridge^7: ^2Loading ^3Items^2 from ^7"..ESXExport)
|
||||||
ESX = exports[ESXExport]:getSharedObject()
|
ESX = exports[ESXExport]:getSharedObject()
|
||||||
Items = ESX.Items
|
Items = ESX.Items
|
||||||
|
else
|
||||||
|
print("^4ERROR^7: ^2No Core Items detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Load Vehicles
|
-- Load Vehicles
|
||||||
@@ -79,6 +93,8 @@ elseif GetResourceState(ESXExport):find("start") then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
else
|
||||||
|
print("^4ERROR^7: ^2No Vehicle info detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Load Jobs
|
-- Load Jobs
|
||||||
@@ -137,6 +153,8 @@ elseif GetResourceState(ESXExport):find("start") then
|
|||||||
Gangs = Jobs
|
Gangs = Jobs
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
else
|
||||||
|
print("^4ERROR^7: ^2No Job/Gang ifo detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
end
|
end
|
||||||
|
|
||||||
function makeBossRoles(role)
|
function makeBossRoles(role)
|
||||||
@@ -179,6 +197,8 @@ function createPoly(data) local Location = nil
|
|||||||
data.onExit()
|
data.onExit()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
else
|
||||||
|
print("^4ERROR^7: ^2No PolyZone creation script detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -196,6 +216,8 @@ function createCirclePoly(data) local Location = nil
|
|||||||
data.onExit()
|
data.onExit()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
else
|
||||||
|
print("^4ERROR^7: ^2No PolyZone creation script detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -364,6 +386,18 @@ function isOx() return (Config.System.Menu == "ox" or Config.System.Menu == "gta
|
|||||||
|
|
||||||
function isWarMenuOpen() if Config.System.Menu == "gta" then return WarMenu.IsAnyMenuOpened() else return false end end
|
function isWarMenuOpen() if Config.System.Menu == "gta" then return WarMenu.IsAnyMenuOpened() else return false end end
|
||||||
|
|
||||||
|
local TextTargets = {}
|
||||||
|
local Keys = {
|
||||||
|
[322] = "ESC", [288] = "F1", [289] = "F2", [170] = "F3", [166] = "F5",
|
||||||
|
[167] = "F6", [168] = "F7", [169] = "F8", [56] = "F9", [57] = "F10",
|
||||||
|
[243] = "~", [157] = "1", [158] = "2", [160] = "3", [164] = "4", [165] = "5", [159] = "6", [161] = "7", [162] = "8", [163] = "9", [84] = "-", [83] = "=", [177] = "BACKSPACE", [37] = "TAB",
|
||||||
|
[44] = "Q", [32] = "W", [38] = "E", [45] = "R", [245] = "T", [246] = "Y", [303] = "U", [199] = "P",
|
||||||
|
[39] = "[", [40] = "]", [18] = "ENTER", [137] = "CAPS",
|
||||||
|
[34] = "A", [8] = "S", [9] = "D", [23] = "F", [47] = "G",
|
||||||
|
[74] = "H", [311] = "K", [182] = "L", [21] = "LEFTSHIFT",
|
||||||
|
[20] = "Z", [73] = "X", [26] = "C", [0] = "V", [29] = "B", [249] = "N",
|
||||||
|
[244] = "M", [82] = ",", [81] = "."
|
||||||
|
}
|
||||||
-- Targets --
|
-- Targets --
|
||||||
local targetEntities = {}
|
local targetEntities = {}
|
||||||
function createEntityTarget(entity, opts, dist)
|
function createEntityTarget(entity, opts, dist)
|
||||||
@@ -392,6 +426,14 @@ function createEntityTarget(entity, opts, dist)
|
|||||||
end
|
end
|
||||||
local options = { options = opts, distance = dist }
|
local options = { options = opts, distance = dist }
|
||||||
exports[QBTargetExport]:AddTargetEntity(entity, options)
|
exports[QBTargetExport]:AddTargetEntity(entity, options)
|
||||||
|
else
|
||||||
|
local tempText = ""
|
||||||
|
local keyTable = { 38, 29, 303, }
|
||||||
|
for i = 1, #opts do
|
||||||
|
opts[i].key = keyTable[i]
|
||||||
|
tempText = tempText.."~b~["..Keys[opts[i].key].."] ~w~"..opts[i].label.." "
|
||||||
|
end
|
||||||
|
TextTargets[entity] = { coords = GetEntityCoords(entity), buttontext = tempText, options = opts, dist = dist }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -435,6 +477,15 @@ function createBoxTarget(data, opts, dist)
|
|||||||
local target = exports[QBTargetExport]:AddBoxZone(data[1], data[2], data[3], data[4], data[5], options)
|
local target = exports[QBTargetExport]:AddBoxZone(data[1], data[2], data[3], data[4], data[5], options)
|
||||||
boxTargets[#boxTargets+1] = target
|
boxTargets[#boxTargets+1] = target
|
||||||
return target
|
return target
|
||||||
|
else
|
||||||
|
local tempText = ""
|
||||||
|
local keyTable = { 38, 29, 303, }
|
||||||
|
for i = 1, #opts do
|
||||||
|
opts[i].key = keyTable[i]
|
||||||
|
tempText = tempText.."~b~["..Keys[opts[i].key].."] ~w~"..opts[i].label.." "
|
||||||
|
end
|
||||||
|
TextTargets[data[1]] = { coords = data[2], buttontext = tempText, options = opts, dist = dist }
|
||||||
|
return data[1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -475,17 +526,57 @@ function createCircleTarget(data, opts, dist)
|
|||||||
|
|
||||||
circleTargets[#circleTargets+1] = target
|
circleTargets[#circleTargets+1] = target
|
||||||
return target
|
return target
|
||||||
|
else
|
||||||
|
local tempText = ""
|
||||||
|
local keyTable = { 38, 29, 303, }
|
||||||
|
for i = 1, #opts do
|
||||||
|
opts[i].key = keyTable[i]
|
||||||
|
tempText = tempText.."~b~["..Keys[opts[i].key].."] ~w~"..opts[i].label.." "
|
||||||
|
end
|
||||||
|
TextTargets[data[1]] = { coords = data[2], buttontext = tempText, options = opts, dist = dist }
|
||||||
|
return data[1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function removeEntityTarget(entity)
|
function removeEntityTarget(entity)
|
||||||
if GetResourceState(QBTargetExport):find("start") then exports[QBTargetExport]:RemoveTargetEntity(entity) end
|
if GetResourceState(QBTargetExport):find("start") then exports[QBTargetExport]:RemoveTargetEntity(entity) end
|
||||||
if GetResourceState(OXTargetExport):find("start") then exports[OXTargetExport]:removeLocalEntity(entity, nil) end
|
if GetResourceState(OXTargetExport):find("start") then exports[OXTargetExport]:removeLocalEntity(entity, nil) end
|
||||||
|
if not GetResourceState(OXTargetExport):find("start") and not GetResourceState(QBTargetExport):find("start") then
|
||||||
|
TextTargets[entity] = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function removeZoneTarget(target)
|
function removeZoneTarget(target)
|
||||||
if GetResourceState(QBTargetExport):find("start") then exports[QBTargetExport]:RemoveZone(target) end
|
if GetResourceState(QBTargetExport):find("start") then exports[QBTargetExport]:RemoveZone(target) end
|
||||||
if GetResourceState(OXTargetExport):find("start") then exports[OXTargetExport]:removeZone(target, true) end
|
if GetResourceState(OXTargetExport):find("start") then exports[OXTargetExport]:removeZone(target, true) end
|
||||||
|
if not GetResourceState(OXTargetExport):find("start") and not GetResourceState(QBTargetExport):find("start") then
|
||||||
|
TextTargets[target] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not GetResourceState(OXTargetExport):find("start") and not GetResourceState(QBTargetExport):find("start") and not IsDuplicityVersion() then
|
||||||
|
CreateThread(function()
|
||||||
|
while true do
|
||||||
|
local pedCoords = GetEntityCoords(PlayerPedId())
|
||||||
|
for k, v in pairs (TextTargets) do
|
||||||
|
if #(pedCoords - v.coords) <= v.dist then
|
||||||
|
DrawText3D(
|
||||||
|
v.coords.x,
|
||||||
|
v.coords.y,
|
||||||
|
v.coords.z + 1.0,
|
||||||
|
v.buttontext
|
||||||
|
)
|
||||||
|
for i = 1, #v.options do
|
||||||
|
if IsControlJustPressed(0, v.options[i].key) then
|
||||||
|
if v.options[i].onSelect then v.options[i].onSelect() end
|
||||||
|
if v.options[i].action then v.options[i].action() end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Wait(0)
|
||||||
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
AddEventHandler('onResourceStop', function(r)
|
AddEventHandler('onResourceStop', function(r)
|
||||||
@@ -644,9 +735,12 @@ function onPlayerLoaded(func)
|
|||||||
elseif GetResourceState(OXCoreExport):find("start") then
|
elseif GetResourceState(OXCoreExport):find("start") then
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3onPlayerLoaded^2 with ^7"..OXLibExport) end
|
if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3onPlayerLoaded^2 with ^7"..OXLibExport) end
|
||||||
AddEventHandler('ox:playerLoaded', func)
|
AddEventHandler('ox:playerLoaded', func)
|
||||||
|
else
|
||||||
|
print("^4ERROR^7: ^2No Core detected for onPlayerLoaded ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- INPUT --
|
-- INPUT --
|
||||||
function createInput(title, opts)
|
function createInput(title, opts)
|
||||||
local dialog = nil
|
local dialog = nil
|
||||||
@@ -656,7 +750,6 @@ function createInput(title, opts)
|
|||||||
if opts[i].type == "radio" then
|
if opts[i].type == "radio" then
|
||||||
for k in pairs(opts[i].options) do
|
for k in pairs(opts[i].options) do
|
||||||
opts[i].options[k].label = opts[i].options[k].text
|
opts[i].options[k].label = opts[i].options[k].text
|
||||||
print(opts[i].options[k].text)
|
|
||||||
end
|
end
|
||||||
options[i] = {
|
options[i] = {
|
||||||
type = "select",
|
type = "select",
|
||||||
@@ -676,6 +769,13 @@ function createInput(title, opts)
|
|||||||
options = opts[i].options,
|
options = opts[i].options,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
if opts[i].type == "text" then
|
||||||
|
options[i] = {
|
||||||
|
type = "input",
|
||||||
|
label = opts[i].text ..(opts[i].txt and " - "..opts[i].txt or ""),
|
||||||
|
isRequired = opts[i].isRequired,
|
||||||
|
}
|
||||||
|
end
|
||||||
if opts[i].type == "select" then
|
if opts[i].type == "select" then
|
||||||
options[i] = {
|
options[i] = {
|
||||||
type = "select",
|
type = "select",
|
||||||
@@ -854,19 +954,24 @@ RegisterNetEvent(GetCurrentResourceName()..":server:ChargePlayer", function(cost
|
|||||||
if type == "cash" then
|
if type == "cash" then
|
||||||
if GetResourceState(OXInv):find("start") then
|
if GetResourceState(OXInv):find("start") then
|
||||||
exports[OXInv]:RemoveItem(src, "money", cost)
|
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
|
elseif GetResourceState(QBExport):find("start") then
|
||||||
Core.Functions.GetPlayer(src).Functions.RemoveMoney("cash", cost)
|
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
|
elseif GetResourceState(ESXExport):find("start") then
|
||||||
local Player = ESX.GetPlayerFromId(src)
|
local Player = ESX.GetPlayerFromId(src)
|
||||||
Player.removeMoney(cost, "")
|
Player.removeMoney(cost, "")
|
||||||
|
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, ESXExport) end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if type == "bank" then
|
if type == "bank" then
|
||||||
if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
||||||
Core.Functions.GetPlayer(src).Functions.RemoveMoney("bank", cost)
|
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
|
elseif GetResourceState(ESXExport):find("start") then
|
||||||
local Player = ESX.GetPlayerFromId(src)
|
local Player = ESX.GetPlayerFromId(src)
|
||||||
Player.removeMoney(cost, "")
|
Player.removeMoney(cost, "")
|
||||||
|
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, ESXExport) end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -885,8 +990,9 @@ function createUseableItem(item, funct)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function hasJob(job, src) local hasJob = false
|
function hasJob(job, source, grade) local hasJob = false
|
||||||
if src then
|
if source then
|
||||||
|
local src = tonumber(source)
|
||||||
if GetResourceState(ESXExport):find("start") then
|
if GetResourceState(ESXExport):find("start") then
|
||||||
local info = ESX.GetPlayerFromId(src).job
|
local info = ESX.GetPlayerFromId(src).job
|
||||||
while not info do
|
while not info do
|
||||||
@@ -905,14 +1011,35 @@ function hasJob(job, src) local hasJob = false
|
|||||||
|
|
||||||
elseif GetResourceState(QBXExport):find("start") then
|
elseif GetResourceState(QBXExport):find("start") then
|
||||||
local jobinfo = exports[QBXExport]:GetPlayer(src).PlayerData.job
|
local jobinfo = exports[QBXExport]:GetPlayer(src).PlayerData.job
|
||||||
if jobinfo.name == job then hasJob = true end
|
if jobinfo.name == job then hasJob = true
|
||||||
|
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
|
||||||
|
end
|
||||||
local ganginfo = exports[QBXExport]:GetPlayer(src).PlayerData.gang
|
local ganginfo = exports[QBXExport]:GetPlayer(src).PlayerData.gang
|
||||||
if ganginfo.name == job then hasJob = true end
|
if ganginfo.name == job then hasJob = true
|
||||||
else
|
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
|
||||||
|
end
|
||||||
|
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
||||||
|
if Core.Functions.GetPlayer then -- support older qb-core functions
|
||||||
|
local jobinfo = Core.Functions.GetPlayer(src).PlayerData.job
|
||||||
|
if jobinfo.name == job then hasJob = true
|
||||||
|
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
|
||||||
|
end
|
||||||
|
local ganginfo = Core.Functions.GetPlayer(src).PlayerData.gang
|
||||||
|
if ganginfo.name == job then hasJob = true
|
||||||
|
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
|
||||||
|
end
|
||||||
|
else -- support newer qb-core exports
|
||||||
local jobinfo = exports[QBExport]:GetPlayer(src).PlayerData.job
|
local jobinfo = exports[QBExport]:GetPlayer(src).PlayerData.job
|
||||||
if jobinfo.name == job then hasJob = true end
|
if jobinfo.name == job then hasJob = true
|
||||||
|
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
|
||||||
|
end
|
||||||
local ganginfo = exports[QBExport]:GetPlayer(src).PlayerData.gang
|
local ganginfo = exports[QBExport]:GetPlayer(src).PlayerData.gang
|
||||||
if ganginfo.name == job then hasJob = true end
|
if ganginfo.name == job then hasJob = true
|
||||||
|
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
|
end
|
||||||
else
|
else
|
||||||
if GetResourceState(ESXExport):find("start") then
|
if GetResourceState(ESXExport):find("start") then
|
||||||
@@ -931,26 +1058,39 @@ function hasJob(job, src) local hasJob = false
|
|||||||
|
|
||||||
elseif GetResourceState(QBXExport):find("start") then
|
elseif GetResourceState(QBXExport):find("start") then
|
||||||
local jobinfo = QBX.PlayerData.job
|
local jobinfo = QBX.PlayerData.job
|
||||||
if jobinfo.name == job then hasJob = true end
|
if jobinfo.name == job then hasJob = true
|
||||||
|
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
|
||||||
|
end
|
||||||
local ganginfo = QBX.PlayerData.gang
|
local ganginfo = QBX.PlayerData.gang
|
||||||
if ganginfo.name == job then hasJob = true end
|
if ganginfo.name == job then hasJob = true
|
||||||
else
|
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
|
||||||
|
end
|
||||||
|
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
||||||
local info = nil
|
local info = nil
|
||||||
Core.Functions.GetPlayerData(function(PlayerData)
|
Core.Functions.GetPlayerData(function(PlayerData)
|
||||||
info = PlayerData
|
info = PlayerData
|
||||||
end)
|
end)
|
||||||
local jobinfo = info.job
|
local jobinfo = info.job
|
||||||
if jobinfo.name == job then hasJob = true end
|
if jobinfo.name == job then
|
||||||
|
hasJob = true
|
||||||
|
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
|
||||||
|
end
|
||||||
local ganginfo = info.gang
|
local ganginfo = info.gang
|
||||||
if ganginfo.name == job then hasJob = true end
|
if ganginfo.name == job then
|
||||||
|
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
|
||||||
end
|
end
|
||||||
return hasJob
|
return hasJob
|
||||||
end
|
end
|
||||||
|
|
||||||
function getPlayer(src) local Player = {}
|
function getPlayer(source) local Player = {}
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Getting ^3Player^2 info^7") end
|
if Config.System.Debug then print("^6Bridge^7: ^2Getting ^3Player^2 info^7") end
|
||||||
if src then -- If called from server
|
if source then -- If called from server
|
||||||
|
local src = tonumber(source)
|
||||||
if GetResourceState(ESXExport):find("start") then
|
if GetResourceState(ESXExport):find("start") then
|
||||||
local info = ESX.GetPlayerFromId(src)
|
local info = ESX.GetPlayerFromId(src)
|
||||||
Player = {
|
Player = {
|
||||||
@@ -977,15 +1117,26 @@ function getPlayer(src) local Player = {}
|
|||||||
bank = info.Functions.GetMoney("bank"),
|
bank = info.Functions.GetMoney("bank"),
|
||||||
}
|
}
|
||||||
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
||||||
local info = Core.Functions.GetPlayer(tonumber(src))
|
if Core.Functions.GetPlayer ~= nil then -- support older qb-core functions
|
||||||
|
local info = Core.Functions.GetPlayer(src).PlayerData
|
||||||
Player = {
|
Player = {
|
||||||
name = info.PlayerData.charinfo.firstname.." "..info.PlayerData.charinfo.lastname,
|
name = info.charinfo.firstname.." "..info.charinfo.lastname,
|
||||||
cash = info.PlayerData.money["cash"],
|
cash = info.money["cash"],
|
||||||
bank = info.PlayerData.money["bank"],
|
bank = info.money["bank"],
|
||||||
|
}
|
||||||
|
else
|
||||||
|
local info = exports[QBExport]:GetPlayer(src).PlayerData
|
||||||
|
Player = {
|
||||||
|
name = info.charinfo.firstname.." "..info.charinfo.lastname,
|
||||||
|
cash = info.money["cash"],
|
||||||
|
bank = info.money["bank"],
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if ESX ~= nil then
|
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
|
||||||
local info = ESX.GetPlayerData()
|
local info = ESX.GetPlayerData()
|
||||||
local cash, bank = 0, 0
|
local cash, bank = 0, 0
|
||||||
for k, v in pairs(ESX.GetPlayerData().accounts) do
|
for k, v in pairs(ESX.GetPlayerData().accounts) do
|
||||||
@@ -1011,16 +1162,16 @@ function getPlayer(src) local Player = {}
|
|||||||
cash = info.money["cash"],
|
cash = info.money["cash"],
|
||||||
bank = info.money["bank"],
|
bank = info.money["bank"],
|
||||||
}
|
}
|
||||||
else
|
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
||||||
local info = nil
|
local info = nil
|
||||||
Core.Functions.GetPlayerData(function(PlayerData)
|
Core.Functions.GetPlayerData(function(PlayerData) info = PlayerData end)
|
||||||
info = PlayerData
|
|
||||||
end)
|
|
||||||
Player = {
|
Player = {
|
||||||
name = info.charinfo.firstname.." "..info.charinfo.lastname,
|
name = info.charinfo.firstname.." "..info.charinfo.lastname,
|
||||||
cash = info.money["cash"],
|
cash = info.money["cash"],
|
||||||
bank = info.money["bank"],
|
bank = info.money["bank"],
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
print("^4ERROR^7: ^2No Core detected for hasJob ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return Player
|
return Player
|
||||||
@@ -1040,13 +1191,15 @@ function invImg(item)
|
|||||||
local imgLink = ""
|
local imgLink = ""
|
||||||
if item ~= "" and Items[item] then
|
if item ~= "" and Items[item] then
|
||||||
if GetResourceState(OXInv):find("start") then
|
if GetResourceState(OXInv):find("start") then
|
||||||
imgLink = "nui://"..OXInv.."/web/images/"..Items[item].image
|
imgLink = "nui://"..OXInv.."/web/images/"..(Items[item].image or "")
|
||||||
elseif GetResourceState(QSInv and QSInv or ""):find("start") then
|
elseif GetResourceState(QSInv and QSInv or ""):find("start") then
|
||||||
imgLink = "nui://"..QSInv.."/html/images/"..Items[item].image
|
imgLink = "nui://"..QSInv.."/html/images/"..(Items[item].image or "")
|
||||||
elseif GetResourceState(CoreInv and CoreInv or ""):find("start") then
|
elseif GetResourceState(CoreInv and CoreInv or ""):find("start") then
|
||||||
imgLink = "nui://"..CoreInv.."/html/img/"..Items[item].image
|
imgLink = "nui://"..CoreInv.."/html/img/"..(Items[item].image or "")
|
||||||
elseif GetResourceState(QBInv and QBInv or ""):find("start") then
|
elseif GetResourceState(QBInv and QBInv or ""):find("start") then
|
||||||
imgLink = "nui://"..QBInv.."/html/images/"..Items[item].image
|
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
|
||||||
end
|
end
|
||||||
return imgLink
|
return imgLink
|
||||||
|
|||||||
Reference in New Issue
Block a user