i have a resource that if player job is “ff” show some markers to him
my job is “ff” but i should restart resource when i come to the server for show markers
Load ESX object and PlayerData code :
ESX = nil
local PlayerData = {}
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
while ESX.GetPlayerData() == nil do
Citizen.Wait(10)
end
PlayerData = ESX.GetPlayerData()
end)
RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
PlayerData.job = job
end)
check if player job is ‘ff’ code :
if PlayerData.job ~= nil and PlayerData.job.name == 'police' then
--
end
the code used to interact with markers :
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if PlayerData.job ~= nil and PlayerData.job.name == 'ff' then
local coords = GetEntityCoords(PlayerPedId())
if GetDistanceBetweenCoords(coords, position.x, position.y, position.z, true) < 20.0 then
cMarker(27, position, scale, color, false, true)
end
if GetDistanceBetweenCoords(coords, position2.x, position2.y, position2.z, true) < 20.0 then
cMarker(27, position2, scale2, color2, false, true)
end
if GetDistanceBetweenCoords(coords, position3.x, position3.y, position3.z, true) < 20.0 then
cMarker(20, position3, scale3, color3, true, false)
end
if GetDistanceBetweenCoords(coords, position4.x, position4.y, position4.z, true) < 20.0 then
cMarker(36, position4, scale4, color4, true, false)
end
if GetDistanceBetweenCoords(coords, position5.x, position5.y, position5.z, true) < 80.0 and IsPedInAnyVehicle(PlayerPedId()) then
cMarker(1, position5, scale5, color5, false, false)
end
if GetDistanceBetweenCoords(coords, position6.x, position6.y, position6.z, true) < 20.0 then
cMarker(27, position6, scale6, color6, false, true)
end
if GetDistanceBetweenCoords(coords, position7.x, position7.y, position7.z, true) < 20.0 then
cMarker(27, position7, scale7, color7, false, true)
end
end
end
end)
cMarker function :
function cMarker(type, position, scale, color, facecamera, rotate)
if facecamera == nil then facecamera = false end
if rotate == nil then rotate = false end
coord = vector3(position.x, position.y, position.z)
DrawMarker(
type,
coord,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
scale.a,
scale.b,
scale.c,
color.r,
color.g,
color.b,
150,
false,
facecamera,
2,
rotate
)
end
positions :
local position, position2, position3, position4, position5, position6, position7 = vector3(190.94, -903.50, 30.81), vector3(177.20, -905.40, 30.81), vector3(181.14, -905.04, 31.10), vector3(174.0, -913.0, 30.40), vector3(162.61, -881.0, 29.40), vector3(179.40, -908.25, 30.81), vector3(187.74, -904.50, 30.81)