Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Idea] QBCore #5

Open
AndreasFromDanmark opened this issue Dec 6, 2022 · 2 comments
Open

[Idea] QBCore #5

AndreasFromDanmark opened this issue Dec 6, 2022 · 2 comments

Comments

@AndreasFromDanmark
Copy link

Hey @gimicze

Can you make this scripts work for QBCore??
image

@gimicze
Copy link
Owner

gimicze commented Dec 15, 2022

Hi!

Unfortunately, I don't have the time to make it work with QBCore. It should be fairly easy to do if you've worked with ESX before as it is already implemented and the code is I believe pretty straight-forward:

--================================--
-- AUTO-SUBSCRIBE --
--================================--
if Config.UnitsRadar.enableESX then
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Config.UnitsRadar.requireItem = Config.UnitsRadar.requireItem and tostring(Config.UnitsRadar.requireItem) or false
local allowedJobs = {}
if type(Config.UnitsRadar.enableESX) == "table" then
for k, v in pairs(Config.UnitsRadar.enableESX) do
allowedJobs[v] = true
end
else
allowedJobs[Config.UnitsRadar.enableESX] = true
end
RegisterNetEvent("esx:setJob")
AddEventHandler(
"esx:setJob",
function(playerId)
local xPlayer = ESX.GetPlayerFromId(playerId)
if xPlayer then
local hasItem = Config.UnitsRadar.requireItem and xPlayer.getInventoryItem(Config.UnitsRadar.requireItem).count > 0 or true
if allowedJobs[xPlayer.job.name] and hasItem then
UnitsRadar:addUnit(playerId)
elseif UnitsRadar.active[playerId] then
UnitsRadar:removeUnit(playerId)
end
end
end
)
RegisterNetEvent("esx:playerLoaded")
AddEventHandler(
"esx:playerLoaded",
function(playerId)
local xPlayer = ESX.GetPlayerFromId(playerId)
if xPlayer then
local hasItem = Config.UnitsRadar.requireItem and xPlayer.getInventoryItem(Config.UnitsRadar.requireItem).count > 0 or true
if allowedJobs[xPlayer.job.name] and hasItem then
UnitsRadar:addUnit(playerId)
elseif UnitsRadar.active[playerId] then
UnitsRadar:removeUnit(playerId)
end
end
end
)
if Config.UnitsRadar.requireItem then
ESX.RegisterUsableItem(
Config.UnitsRadar.requireItem,
function(source)
local xPlayer = ESX.GetPlayerFromId(source)
if allowedJobs[xPlayer.job.name] and not UnitsRadar.active[source] then
UnitsRadar:addUnit(source)
elseif UnitsRadar.active[source] then
UnitsRadar:removeUnit(source)
end
end
)
end
end

One of the reasons many authors upload their projects to GitHub is that once it's online, anyone can contribute. If I get a pull request, I'd be happy to review it.

Sorry I couldn't be of a better help. Will leave this issue open in case anyone wants to improve the script :-)

@g4met11
Copy link

g4met11 commented Jan 4, 2023

@AndreasFromDanmark
DA:
Jeg har lige lavet en pull request og håber på den bliver accepter, den vil tilføje QBCore support til scriptet
EN:
Ive just made a pull request for the script and hopes it gets accepted and it will give the script QBCore support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants