How to check if player is near truck?

Hi,

i’m trying to make a script that you take a box and then load it on truck… but i dont know how to check if player is near to truck and if its a truck so he can load it. I’ve tried research on forumos and i can’t find anything to do this… i’m looking on other scripts but i dont understand… how i get

Something like this?

local coords = GetEntityCoords(playerPed)
local vehicleid = GetClosestVehicle(coords.x, coords.y, coords.z, 100.0, 0)

I can’t get it working :S

if you use ESX , esx has function for that

Yes i’m using ESX,

I’ve tried:

local pos = GetEntityCoords(GetPlayerPed(-1))
local vehicle = GetClosestVehicle(pos[‘x’], pos[‘y’], pos[‘z’], 5.001, 0, 70)

and its working for the truck and personal cars (not police)

so i’m going to do it that way it works :d i’, i’m going to learn docs thanks !

1 Like