forked from Mesrine67/Ricky-MDT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.lua
163 lines (142 loc) · 4.48 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
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
local ESX = exports.es_extended:getSharedObject()
local PlayerData = {}
local opened = false
Citizen.CreateThread(function()
while ESX.IsPlayerLoaded() == false do Wait(0) end
PlayerData = ESX.GetPlayerData()
end)
SonoSbirro = function()
local job = PlayerData.job.name
for k,v in pairs(Config.PoliceJob) do
if job == v then
return true
end
end
return false
end
RegisterCommand('mdt', function(source, args, rawCommand)
OpenMDT()
end)
postNUI = function(data)
SendNUIMessage(data)
end
RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
postNUI({
type = "UPDATE_OFFICER_JOB",
job = {
name = job.name,
label = job.label,
grade = {
name = job.grade_name,
label = job.grade_label
}
}
})
PlayerData.job = job
end)
RegisterNetEvent("esx:playerLoaded")
AddEventHandler("esx:playerLoaded", function (xPlayer)
PlayerData = xPlayer
end)
RegisterNUICallback('setGps', function(data, cb)
SetNuiFocus(false, false)
SetNewWaypoint(data.x, data.y)
ESX.ShowNotification(Config.Translate[Config.Language]["set_gps"])
end)
OpenMDT = function()
ESX.TriggerServerCallback('ricky-server:mdtGetStartInfo', function(officerInfo, cittadini, veicoli, allReports, numeroSbirri)
if not SonoSbirro() then return end
if opened then return end
if PlayerData.job.grade >= Config.HighGrade then
postNUI({
type = "ACCESS_LIST_REPORT",
reports = allReports
})
end
postNUI({
type = "UPDATE_OFFICER_NUMBER",
officerNumber = numeroSbirri
})
postNUI({
type = "UPDATE_CONFIG",
config = Config
})
if cittadini == nil then return end
-- if Config.HouseSystem == 'allhousing' then
for k,v in pairs(cittadini) do
for a,b in pairs(v.case) do
b.name = GetStreetNameAtCoord(b.x, b.y, b.z)
b.name = GetStreetNameFromHashKey(b.name)
end
end
-- end
SetNuiFocus(true, true)
postNUI({
type = "OPEN_MDT",
officerInfo = officerInfo,
cittadini = cittadini,
veicoli = veicoli
})
opened = true
end)
end
RegisterNUICallback('addWanted', function(data, cb)
local identifier = data.identifier
TriggerServerEvent('ricky-server:mdtAddWanted', identifier)
end)
RegisterNUICallback('removeWanted', function(data, cb)
local identifier = data.identifier
TriggerServerEvent('ricky-server:mdtRemoveWanted', identifier)
end)
RegisterNUICallback('updateNote', function(data, cb)
local identifier = data.identifier
local note = data.note
TriggerServerEvent('ricky-server:mdtUpdateNote', identifier, note)
end)
RegisterNUICallback('close', function(data, cb)
SetNuiFocus(false, false)
opened = false
end)
RegisterNetEvent('ricky-client:mdtUpdateCittadini')
AddEventHandler('ricky-client:mdtUpdateCittadini', function()
ESX.TriggerServerCallback('ricky-server:mdtGetStartInfo', function(officerInfo, cittadini, veicoli)
-- if Config.HouseSystem == 'allhousing' then
for k,v in pairs(cittadini) do
for a,b in pairs(v.case) do
b.name = GetStreetNameAtCoord(b.x, b.y, b.z)
b.name = GetStreetNameFromHashKey(b.name)
end
end
-- end
postNUI({
type = "UPDATE_CITTADINI",
cittadini = cittadini
})
postNUI({
type = "UPDATE_VEICOLI",
veicoli = veicoli
})
postNUI({
type = "UPDATE_OFFICER_INFO",
officerInfo = officerInfo
})
end)
end)
RegisterNUICallback('addReato', function(data, cb)
local identifier = data.identifier
local reason = data.reason
TriggerServerEvent('ricky-server:mdtAddReato', identifier, reason)
end)
RegisterNUICallback('deleteReato', function(data, cb)
local identifier = data.identifier
local idReato = data.idReato
TriggerServerEvent('ricky-server:mdtDeleteReato', identifier, idReato)
end)
RegisterNUICallback('createReport', function(data, cb)
local rapporto = data.rapporto
TriggerServerEvent('ricky-server:mdtCreateReport', rapporto)
end)
RegisterCommand('mdt', function(source, args, rawCommand)
OpenMDT()
end)