Repository navigation
Expand file tree
/
Copy pathclient.lua
More file actions
95 lines (76 loc) · 2.73 KB
/
Copy pathclient.lua
File metadata and controls
95 lines (76 loc) · 2.73 KB
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
89
90
91
92
93
94
95
local showCoords = false
function displayCoords(x, y, z, heading)
SetTextFont(4)
SetTextProportional(1)
SetTextScale(0.5, 0.5)
SetTextEntry("STRING")
SetTextColour(0, 255, 255, 255)
AddTextComponentString(string.format("X: %.2f | Y: %.2f | Z: %.2f | Heading: %.2f", x, y, z, heading))
DrawText(0.6, 0.9)
end
function displayStreetNames(streetName, crossStreetName)
SetTextFont(4)
SetTextProportional(1)
SetTextScale(0.6, 0.6)
SetTextEntry("STRING")
SetTextColour(178, 34, 34, 255)
AddTextComponentString(string.format("Street: %s | Cross Street: %s", streetName, crossStreetName))
DrawText(0.5, 0.85)
end
function displayChatCoordinates()
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
local playerHeading = GetEntityHeading(playerPed)
local x = string.format("~r~X: %.2f", playerCoords.x)
local y = string.format("~g~Y: %.2f", playerCoords.y)
local z = string.format("~b~Z: %.2f", playerCoords.z)
local heading = string.format("~m~Heading: %.2f", playerHeading)
TriggerEvent('chat:addMessage', {
color = { 255, 255, 255 },
multiline = true,
args = { "Coordinates", string.format("%s, %s, %s | %s", x, y, z, heading) }
})
end
RegisterCommand('coords', function()
showCoords = not showCoords
if showCoords then
displayChatCoordinates()
print("Coordinates display enabled.")
Citizen.CreateThread(function()
while showCoords do
Citizen.Wait(5000)
displayChatCoordinates()
end
end)
else
TriggerEvent('chat:addMessage', {
color = { 255, 0, 0 },
multiline = true,
args = { "Coordinates", "Coordinates display toggled off." }
})
print("Coordinates display disabled.")
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(12)
local playerID = PlayerPedId()
local playerCoordinates = GetEntityCoords(playerID)
local streetHash, crossStreetHash = GetStreetNameAtCoord(table.unpack(playerCoordinates))
local streetName = GetStreetNameFromHashKey(streetHash)
local crossStreetName = GetStreetNameFromHashKey(crossStreetHash)
if showCoords then
displayStreetNames(streetName, crossStreetName)
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if showCoords then
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
displayCoords(coords.x, coords.y, coords.z, GetEntityHeading(playerPed))
end
end
end)