diff --git a/client/peds.lua b/client/peds.lua index 7f7e08f..329ef46 100644 --- a/client/peds.lua +++ b/client/peds.lua @@ -1,5 +1,6 @@ local target, ox_target local locations = {} +local pedBlips = {} local clothingComponents = { face = 0, mask = 1, @@ -51,8 +52,28 @@ local function setClothing(ped, clothing) end end -local function createBlip(coords, info) +local function groupCheck(groups, playerGroups) + if not groups or #groups == 0 then return true end + for i=1, #groups do + if playerGroups and playerGroups[groups[i]] then + return true + end + end +end + +local function createBlip(coords, info, i) if not info then return end + local groups = info.groups + local playerGroups = NDCore.player?.groups + + local key = i or #pedBlips+1 + pedBlips[key] = { + groups = groups, + info = info, + coords = coords + } + + if not groupCheck(groups, playerGroups) then return end local blip = AddBlipForCoord(coords.x, coords.y, coords.z) SetBlipSprite(blip, info.sprite or 280) SetBlipScale(blip, info.scale or 0.8) @@ -63,9 +84,23 @@ local function createBlip(coords, info) AddTextComponentString(info.label) EndTextCommandSetBlipName(blip) end + + pedBlips[key].blip = blip return blip end +local function updateBlips(playerGroups) + for i=1, #pedBlips do + local blipInfo = pedBlips[i] + local access = groupCheck(blipInfo.groups, playerGroups) + if access and not blipInfo.blip or not DoesBlipExist(blipInfo.blip) then + createBlip(blipInfo.coords, blipInfo.info, i) + elseif not access and blipInfo.blip and DoesBlipExist(blipInfo.blip) then + RemoveBlip(blipInfo.blip) + end + end +end + function NDCore.createAiPed(info) local ped local model = type(info.model) == "string" and GetHashKey(info.model) or info.model @@ -148,6 +183,18 @@ function NDCore.removeAiPed(id) end end +RegisterNetEvent("ND:updateCharacter", function(character) + Wait(3000) + if character.id ~= NDCore.player?.id then return end + updateBlips(character.groups) +end) + +RegisterNetEvent("ND:characterLoaded", function(character) + Wait(3000) + if character.id ~= NDCore.player?.id then return end + updateBlips(character.groups) +end) + AddEventHandler("onResourceStop", function(name) if name == GetCurrentResourceName() then for i, _ in ipairs(locations) do diff --git a/client/vehicle/garages.lua b/client/vehicle/garages.lua index 68e9616..c0ade99 100644 --- a/client/vehicle/garages.lua +++ b/client/vehicle/garages.lua @@ -231,7 +231,8 @@ for i=1, #locations do label = ("Parking garage (%s)"):format(location.garageType), sprite = sprite[location.garageType], scale = 0.7, - color = 3 + color = 3, + groups = location.groups }, anim = { dict = "anim@amb@casino@valet_scenario@pose_d@",