-
Notifications
You must be signed in to change notification settings - Fork 5
/
utils.lua
35 lines (33 loc) · 1.06 KB
/
utils.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function isCloseVeh()
local ped = PlayerPedId()
coordA = GetEntityCoords(ped, 1)
coordB = GetOffsetFromEntityInWorldCoords(ped, 0.0, 100.0, 0.0)
vehicle = getVehicleInDirection(coordA, coordB)
if DoesEntityExist(vehicle) and NetworkHasControlOfEntity(vehicle) then
return true
end
return false
end
function getVehicleInDirection(coordFrom, coordTo)
local offset = 0
local rayHandle
local vehicle
for i = 0, 100 do
rayHandle = CastRayPointToPoint(coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z + offset, 10, PlayerPedId(), 0)
a, b, c, d, vehicle = GetRaycastResult(rayHandle)
offset = offset - 1
if vehicle ~= 0 then break end
end
local distance = Vdist2(coordFrom, GetEntityCoords(vehicle))
if distance > 25 then vehicle = nil end
return vehicle ~= nil and vehicle or 0
end
function hasEnoughOfItem(item)
local retval = false
QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
if result then
retval = true
end
return retval
end, item)
end