-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.lua
More file actions
173 lines (150 loc) · 3.84 KB
/
client.lua
File metadata and controls
173 lines (150 loc) · 3.84 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
local ped = nil
local PlayerData, data = nil, {}
local function GetMinimapAnchor()
local minimap = {}
local resX, resY = GetActiveScreenResolution()
local aspectRatio = GetAspectRatio()
local scaleX = 1/resX
local scaleY = 1/resY
local minimapRawX, minimapRawY
SetScriptGfxAlign(string.byte('L'), string.byte('B'))
if IsBigmapActive() then
minimapRawX, minimapRawY = GetScriptGfxPosition(-0.003975, 0.022 + (-0.460416666))
minimap.width = scaleX*(resX/(2.52*aspectRatio))
minimap.height = scaleY*(resY/(2.3374))
else
minimapRawX, minimapRawY = GetScriptGfxPosition(-0.0045, 0.002 + (-0.188888))
minimap.width = scaleX*(resX/(4*aspectRatio))
minimap.height = scaleY*(resY/(5.674))
end
ResetScriptGfxAlign()
minimap.leftX = minimapRawX
minimap.rightX = minimapRawX+minimap.width
minimap.topY = minimapRawY
minimap.bottomY = minimapRawY+minimap.height
minimap.X = minimapRawX+(minimap.width/2)
minimap.Y = minimapRawY+(minimap.height/2)
return {
x = minimap.leftX+0.005,
y = minimap.topY+0.014,
height = minimap.height,
right_x = minimap.rightX+0.005,
}
end
local function getInfo()
data[#data+1] = {
name = 'job',
value = PlayerData.job.label .. ' - ' .. PlayerData.job.grade_label
}
for i=1, #PlayerData.accounts, 1 do
local account = PlayerData.accounts[i]
data[#data+1] = {
name = account.name,
value = account.money
}
end
PlayerData = nil
return data
end
-- Events
RegisterNetEvent('esx:setAccountMoney', function(account)
for i=1, #data, 1 do
if data[i].name == account.name then
data[i].value = account.money
break
end
end
SendNUIMessage({
ui = 'updateInfo',
data = data
})
end)
RegisterNetEvent('esx:setJob', function(job)
for i=1, #data, 1 do
if data[i].name == 'job' then
data[i].value = job.label .. ' - ' .. job.grade_label
break
end
end
SendNUIMessage({
ui = 'updateInfo',
data = data
})
end)
RegisterNetEvent('esx:playerLoaded', function(playerData)
Wait(100)
ped = PlayerPedId()
PlayerData = {
job = playerData.job,
accounts = playerData.accounts
}
SendNUIMessage({
ui = 'init',
show = true,
data = GetMinimapAnchor()
})
SendNUIMessage({
ui = 'updateInfo',
data = getInfo()
})
end)
AddEventHandler('esx_status:onTick', function(data)
local status = {}
for i=1, #data, 1 do
status[#status + 1] = {
name = data[i].name,
percent = data[i].percent
}
end
status[#status + 1] = {
percent = GetEntityHealth(ped) - 100 > 0 and GetEntityHealth(ped) - 100 or 0,
name = 'health'
}
status[#status + 1] = {
percent = GetPedArmour(ped),
name = 'armor'
}
SendNUIMessage({
ui = 'updateStatus',
data = status
})
if IsPauseMenuActive() then
SendNUIMessage({
ui = 'show',
show = false,
})
else
SendNUIMessage({
ui = 'show',
show = true,
})
end
end)
-- End events
CreateThread(function()
if ESX.PlayerLoaded then
Wait(100)
ped = PlayerPedId()
PlayerData = {
job = ESX.GetPlayerData().job,
accounts = ESX.GetPlayerData().accounts
}
SendNUIMessage({
ui = 'init',
show = true,
data = GetMinimapAnchor()
})
SendNUIMessage({
ui = 'updateInfo',
data = getInfo()
})
end
end)
-- Use this when changing res
RegisterCommand('fixui', function()
SendNUIMessage({
ui = 'init',
show = true,
data = GetMinimapAnchor()
})
end)