-
Notifications
You must be signed in to change notification settings - Fork 4
/
functions_client.lua
88 lines (69 loc) · 1.87 KB
/
functions_client.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
function GetFuel(vehicle)
return DecorGetFloat(vehicle, Config.FuelDecor)
end
function SetFuel(vehicle, fuel)
if type(fuel) == 'number' and fuel >= 0 and fuel <= 100 then
SetVehicleFuelLevel(vehicle, fuel + 0.0)
DecorSetFloat(vehicle, Config.FuelDecor, GetVehicleFuelLevel(vehicle))
end
end
function LoadAnimDict(dict)
if not HasAnimDictLoaded(dict) then
RequestAnimDict(dict)
while not HasAnimDictLoaded(dict) do
Citizen.Wait(1)
end
end
end
function DrawText3Ds(x, y, z, text)
local onScreen,_x,_y=World3dToScreen2d(x,y,z)
if onScreen then
SetTextScale(0.35, 0.35)
SetTextFont(4)
SetTextProportional(1)
SetTextColour(255, 255, 255, 215)
SetTextEntry("STRING")
SetTextCentre(1)
AddTextComponentString(text)
DrawText(_x,_y)
end
end
function Round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end
function CreateBlip(coords)
local blip = AddBlipForCoord(coords)
SetBlipSprite(blip, 361)
SetBlipScale(blip, 0.9)
SetBlipColour(blip, 4)
SetBlipDisplay(blip, 4)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("Gas Station")
EndTextCommandSetBlipName(blip)
return blip
end
function FindNearestFuelPump()
local coords = GetEntityCoords(PlayerPedId())
local fuelPumps = {}
local handle, object = FindFirstObject()
local success
repeat
if Config.PumpModels[GetEntityModel(object)] then
table.insert(fuelPumps, object)
end
success, object = FindNextObject(handle, object)
until not success
EndFindObject(handle)
local pumpObject = 0
local pumpDistance = 1000
for _, fuelPumpObject in pairs(fuelPumps) do
local dstcheck = GetDistanceBetweenCoords(coords, GetEntityCoords(fuelPumpObject))
if dstcheck < pumpDistance then
pumpDistance = dstcheck
pumpObject = fuelPumpObject
end
end
return pumpObject, pumpDistance
end