mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
feat: ped blip shown by group if added
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
local target, ox_target
|
local target, ox_target
|
||||||
local locations = {}
|
local locations = {}
|
||||||
|
local pedBlips = {}
|
||||||
local clothingComponents = {
|
local clothingComponents = {
|
||||||
face = 0,
|
face = 0,
|
||||||
mask = 1,
|
mask = 1,
|
||||||
@@ -51,8 +52,28 @@ local function setClothing(ped, clothing)
|
|||||||
end
|
end
|
||||||
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
|
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)
|
local blip = AddBlipForCoord(coords.x, coords.y, coords.z)
|
||||||
SetBlipSprite(blip, info.sprite or 280)
|
SetBlipSprite(blip, info.sprite or 280)
|
||||||
SetBlipScale(blip, info.scale or 0.8)
|
SetBlipScale(blip, info.scale or 0.8)
|
||||||
@@ -63,9 +84,23 @@ local function createBlip(coords, info)
|
|||||||
AddTextComponentString(info.label)
|
AddTextComponentString(info.label)
|
||||||
EndTextCommandSetBlipName(blip)
|
EndTextCommandSetBlipName(blip)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
pedBlips[key].blip = blip
|
||||||
return blip
|
return blip
|
||||||
end
|
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)
|
function NDCore.createAiPed(info)
|
||||||
local ped
|
local ped
|
||||||
local model = type(info.model) == "string" and GetHashKey(info.model) or info.model
|
local model = type(info.model) == "string" and GetHashKey(info.model) or info.model
|
||||||
@@ -148,6 +183,18 @@ function NDCore.removeAiPed(id)
|
|||||||
end
|
end
|
||||||
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)
|
AddEventHandler("onResourceStop", function(name)
|
||||||
if name == GetCurrentResourceName() then
|
if name == GetCurrentResourceName() then
|
||||||
for i, _ in ipairs(locations) do
|
for i, _ in ipairs(locations) do
|
||||||
|
|||||||
@@ -231,7 +231,8 @@ for i=1, #locations do
|
|||||||
label = ("Parking garage (%s)"):format(location.garageType),
|
label = ("Parking garage (%s)"):format(location.garageType),
|
||||||
sprite = sprite[location.garageType],
|
sprite = sprite[location.garageType],
|
||||||
scale = 0.7,
|
scale = 0.7,
|
||||||
color = 3
|
color = 3,
|
||||||
|
groups = location.groups
|
||||||
},
|
},
|
||||||
anim = {
|
anim = {
|
||||||
dict = "anim@amb@casino@valet_scenario@pose_d@",
|
dict = "anim@amb@casino@valet_scenario@pose_d@",
|
||||||
|
|||||||
Reference in New Issue
Block a user