hello , i do this, it’s works for me, can use only specific jobs
Here , job is blackmarket
ESX = nil
local PlayerData = {}
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
end)
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
PlayerData = xPlayer
Citizen.Wait(10000)
end)
RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
PlayerData.job = job
end)
Citizen.CreateThread(function ()
while true do
if PlayerData.job ~= nil and PlayerData.job.name == "blackmarket" then
Citizen.Wait(5)
local player = GetPlayerPed(-1)
local playerLoc = GetEntityCoords(player)
for _,location in ipairs(positions) do
teleport_text = location[4]
pos1 = {
x=location[1][1],
y=location[1][2],
z=location[1][3],
heading=location[1][4]
}
pos2 = {
x=location[2][1],
y=location[2][2],
z=location[2][3],
heading=location[2][4]
}
ColorRed = location[3][1]
ColorGreen = location[3][2]
ColorBlue = location[3][3]
vechicle = location[5]
MarkerType = location[6]
PressKey = location[9]
range = {
p1=location[10][1],
p2=location[10][2],
p3=location[10][3],
}
DrawMarker(MarkerType, pos1.x, pos1.y, pos1.z, 0, 0, 0, 0, 0, 0, range.p1, range.p2, range.p3, ColorRed, ColorGreen, ColorBlue, 200, 0, 0, 0, 1)
if position_verf(playerLoc.x, playerLoc.y, playerLoc.z, pos1.x, pos1.y, pos1.z, 2) then
help_message(teleport_text)
if IsControlJustReleased(1, PressKey) then
if vechicle == true then
if IsPedInAnyVehicle(player, true) then
FreezeEntityPosition(player, true)
DoScreenFadeOut(500)
Citizen.Wait(500)
DoScreenFadeIn(500)
FreezeEntityPosition(player, false)
SetEntityCoords(GetVehiclePedIsUsing(player), pos2.x, pos2.y, pos2.z)
SetEntityHeading(GetVehiclePedIsUsing(player), pos2.heading)
else
FreezeEntityPosition(player, true)
DoScreenFadeOut(500)
Citizen.Wait(500)
DoScreenFadeIn(500)
FreezeEntityPosition(player, false)
SetEntityCoords(player, pos2.x, pos2.y, pos2.z)
SetEntityHeading(player, pos2.heading)
notify_message(novehcile_message)
end
elseif vechicle == false then
if IsPedInAnyVehicle(player, true) then
notify_message(vehicle_message)
else
FreezeEntityPosition(player, true)
DoScreenFadeOut(500)
Citizen.Wait(500)
DoScreenFadeIn(500)
FreezeEntityPosition(player, false)
SetEntityCoords(player, pos2.x, pos2.y, pos2.z)
SetEntityHeading(player, pos2.heading)
end
end
end
end
end
else
Citizen.Wait(500)
end
end
end)