Skip to content

Commit

Permalink
Bugfix?
Browse files Browse the repository at this point in the history
  • Loading branch information
gimicze committed Mar 21, 2021
1 parent 470d890 commit 285d088
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Config.UnitsRadar = {
},
panicColor = 10, -- The color of the route to a panic - set to false or nil if you don't want to enable /panic; See "HUD Colors" (https://wiki.rage.mp/index.php?title=Fonts_and_Colors)
enableESX = "police", -- Set to false if you don't want to use ESX jobs, if you do you can change this to the name of your police job; Can be a table containing a list of allowed jobs - for example {'police', 'ambulance'}
requireItem = "gps", -- Enabled only if you're using ESX (enableESX must be filled in); Sets the required item for the dispatch to register officers onto the map, registers it as usable -> officers may use the item to turn the radar on if it wasn't turned on automatically
requireItem = false, -- Enabled only if you're using ESX (enableESX must be filled in); Sets the required item for the dispatch to register officers onto the map, registers it as usable -> officers may use the item to turn the radar on if it wasn't turned on automatically
bigmapKey = false, -- Set to a specific key to automatically bind the extend / shrink functionality of the minimap; Set to false if you don't want to use the functionality; Set to true if you don't want to set default keybind
usePlayerBlips = true, -- When true, the script will only show blips for distant players (OneSync Infinity/Beyond)
announceDuty = true -- Set to true if you want to send every unit a message about other units going on/off duty
Expand Down
24 changes: 16 additions & 8 deletions server/units.lua
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,15 @@ if Config.UnitsRadar.enableESX then
"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 (not Config.UnitsRadar.requireItem or xPlayer.getInventoryItem(Config.UnitsRadar.requireItem).count > 0) then
UnitsRadar:addUnit(playerId)
elseif UnitsRadar.active[playerId] then
UnitsRadar:removeUnit(playerId)
if allowedJobs[xPlayer.job.name] and hasItem then
UnitsRadar:addUnit(playerId)
elseif UnitsRadar.active[playerId] then
UnitsRadar:removeUnit(playerId)
end
end
end
)
Expand All @@ -389,10 +393,14 @@ if Config.UnitsRadar.enableESX then
function(playerId)
local xPlayer = ESX.GetPlayerFromId(playerId)

if allowedJobs[xPlayer.job.name] and not UnitsRadar.active[playerId] and (not Config.UnitsRadar.requireItem or xPlayer.getInventoryItem(Config.UnitsRadar.requireItem).count > 0) then
UnitsRadar:addUnit(playerId)
elseif UnitsRadar.active[playerId] then
UnitsRadar:removeUnit(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
)
Expand Down

0 comments on commit 285d088

Please sign in to comment.