This repository has been archived by the owner on Dec 18, 2023. It is now read-only.
forked from codibez/streetlabel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.lua
83 lines (69 loc) · 1.7 KB
/
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
-- Variables
local directions = {
N = 360, 0,
NE = 315,
E = 270,
SE = 225,
S = 180,
SW = 135,
W = 90,
NW = 45
-- N = 0, <= will result in the HUD breaking above 315deg
}
local veh = 0;
local hash1, hash2, heading;
Citizen.CreateThread(function()
-- Wait a single second before sending data NUI message :?
Citizen.Wait(1000);
SendNUIMessage({
type = 'streetLabel:DATA',
color = config.color,
offsetX = config.position.offsetX,
offsetY = config.position.offsetY,
scale = config.scale,
dynamic = config.dynamic
});
while true do
local ped = GetPlayerPed(-1);
local veh = GetVehiclePedIsIn(ped, false);
local coords = GetEntityCoords(PlayerPedId());
local zone = GetNameOfZone(coords.x, coords.y, coords.z);
local zoneLabel = GetLabelText(zone);
if(config.vehicleCheck == false or veh ~= 0) then
local var1, var2 = GetStreetNameAtCoord(coords.x, coords.y, coords.z, Citizen.ResultAsInteger(), Citizen.ResultAsInteger())
hash1 = GetStreetNameFromHashKey(var1);
hash2 = GetStreetNameFromHashKey(var2);
heading = GetEntityHeading(PlayerPedId());
for k, v in pairs(directions) do
if (math.abs(heading - v) < 22.5) then
heading = k;
if (heading == 1) then
heading = 'N';
break;
end
break;
end
end
local street2;
if (hash2 == '') then
street2 = zoneLabel;
else
street2 = hash2..', '..zoneLabel;
end
SendNUIMessage({
type = 'streetLabel:MSG',
active = true,
direction = heading,
street = hash1,
zone = street2
});
else
SendNUIMessage({
type = 'streetLabel:MSG',
active = false
});
end
-- Wait for half a second.
Citizen.Wait(500);
end
end)