-
Notifications
You must be signed in to change notification settings - Fork 19
/
client.lua
295 lines (267 loc) · 9.6 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
local coreLoaded = false
local nuiFocus = false
local tab = 0
local PlayerData = {}
ESX = nil
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(100)
end
coreLoaded = true
while ESX.GetPlayerData().job == nil do Citizen.Wait(100) end
firstLogin()
end)
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function()
firstLogin()
end)
RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
PlayerData.job = job
firstLogin()
end)
function firstLogin()
PlayerData = ESX.GetPlayerData()
ESX.TriggerServerCallback("tgiann-mdtv2:ilk-data", function(result, items, playerName)
local firstData = {}
firstData.name = playerName
firstData.rank = PlayerData.job.label
firstData.items = {}
for item, data in pairs(items) do
table.insert(firstData.items, data.label)
end
firstData.players = result
firstData.lang = lang[langSetting]
firstData.resourceName = GetCurrentResourceName()
SendNUIMessage({type = 'ilk-bilgi', data = firstData})
end)
end
RegisterNUICallback('sorgula', function(data, cb)
local sorguData = nil
ESX.TriggerServerCallback("tgiann-mdtv2:sorgula", function(result)
sorguData = result
end, data)
while sorguData == nil do Citizen.Wait(0) end
cb(sorguData)
end)
RegisterNUICallback('photo', function(data, cb)
local cbComplated = false
ESX.TriggerServerCallback("tgiann-mdtv2:photo", function(result)
sorguData = result
cbComplated = true
end, data)
while not cbComplated do Citizen.Wait(0) end
cb(sorguData)
end)
RegisterNUICallback('cezakaydetclient', function(data)
TriggerServerEvent("tgiann-mdtv2:ceza-kaydet", data.data)
end)
local olaylarDataLast = nil
local olaylarDataTime = 0
RegisterNUICallback('olaylardata', function(data, cb)
if GetGameTimer() > olaylarDataTime or olaylarDataTime == 0 then
olaylarDataTime = GetGameTimer() + 30000
ESX.TriggerServerCallback("tgiann-mdtv2:olaylardata", function(result)
olaylarDataLast = result
cb(result)
end)
else
cb(olaylarDataLast)
end
end)
local sabikaDataLast = nil
local sabikaDataTime = 0
RegisterNUICallback('sabikadata', function(data, cb)
if GetGameTimer() > sabikaDataTime or sabikaDataTime == 0 then
sabikaDataTime = GetGameTimer() + 30000
ESX.TriggerServerCallback("tgiann-mdtv2:sabikadata", function(result)
sabikaDataLast = result
cb(result)
end, data.id)
else
cb(sabikaDataLast)
end
end)
RegisterNUICallback('sabikasil', function(data, cb)
TriggerServerEvent("tgiann-mdtv2:sabikasil", data.id)
end)
RegisterNUICallback('resim', function(data, cb)
if data.url then
TriggerServerEvent("tgiann-mdtv2:setavatar", data.url, data.id)
else
CreateMobilePhone(1)
CellCamActivate(true, true)
takePhoto = true
if nuiFocus then openClose() end
while takePhoto do
Citizen.Wait(0)
if IsControlJustPressed(1, 177) then -- CANCEL
DestroyMobilePhone()
CellCamActivate(false, false)
takePhoto = false
elseif IsControlJustPressed(1, 176) then -- TAKE.. PIC
local url = screenShot()
if url then
SendNUIMessage({type = 'user-avatar', url = url})
TriggerServerEvent("tgiann-mdtv2:setavatar", url, data.id)
else
local text = lang[langSetting]["photoError"]
if Config.Notify == 'esx' then
ESX.ShowNotification(text)
elseif Config.Notify == 'mythic' then
exports['mythic_notify']:SendAlert('error', text, 2500)
end
end
openClose()
DestroyMobilePhone()
CellCamActivate(false, false)
takePhoto = false
end
HideHudComponentThisFrame(7)
HideHudComponentThisFrame(8)
HideHudComponentThisFrame(9)
HideHudComponentThisFrame(6)
HideHudComponentThisFrame(19)
HideHudAndRadarThisFrame()
end
end
end)
local screenShotCD = 0
function screenShot()
local callbackData = nil
screenShotCD = 0
exports['screenshot-basic']:requestScreenshotUpload(Config.Webhook, "files[]", function(data)
callbackData = json.decode(data)
end)
while callbackData == nil do
Citizen.Wait(1000)
screenShotCD = screenShotCD + 1
if screenShotCD > 10 then
break
end
end
if callbackData then
if callbackData.message then
print(lang[langSetting]["f8error"].." "..callbackData.message)
return false
else
return callbackData.attachments[1].proxy_url
end
else
print(lang[langSetting]["f8error"].." "..lang[langSetting]["photoError"])
return lang[langSetting]["photoError"]
end
end
function openClose()
nuiFocus = not nuiFocus
SetNuiFocus(nuiFocus, nuiFocus)
if nuiFocus then
startAnim()
SendNUIMessage({type = 'open'})
else
stopAnim()
SendNUIMessage({type = 'close'})
end
end
function stopAnim()
StopAnimTask(PlayerPedId(), "amb@code_human_in_bus_passenger_idles@female@tablet@idle_a", "idle_a" ,8.0, -8.0, -1, 50, 0, false, false, false)
DeleteObject(tab)
end
function startAnim()
RequestAnimDict("amb@code_human_in_bus_passenger_idles@female@tablet@idle_a")
while not HasAnimDictLoaded("amb@code_human_in_bus_passenger_idles@female@tablet@idle_a") do
Citizen.Wait(0)
end
TaskPlayAnim(PlayerPedId(), "amb@code_human_in_bus_passenger_idles@female@tablet@idle_a", "idle_a" ,8.0, -8.0, -1, 50, 0, false, false, false)
tab = CreateObject(GetHashKey("prop_cs_tablet"), 0, 0, 0, true, true, true)
AttachEntityToEntity(tab, PlayerPedId(), GetPedBoneIndex(PlayerPedId(), 28422), -0.05, 0.0, 0.0, 0.0, 0.0, 0.0, true, true, false, true, 1, true)
end
RegisterNUICallback('aranma', function(data, cb)
TriggerServerEvent("tgiann-mdtv2:aranma", data, true)
end)
RegisterNUICallback('aranmakaldir', function(data, cb)
TriggerServerEvent("tgiann-mdtv2:aranma", data, false)
end)
RegisterNUICallback('arananlar', function(data, cb)
ESX.TriggerServerCallback("tgiann-mdtv2:arananlar", function(result)
cb(result)
end)
end)
RegisterNUICallback('ev', function(data, cb)
ESX.TriggerServerCallback("tgiann-mdtv2:ev", function(result)
cb(result)
end,data.id)
end)
RegisterNUICallback('olaysil', function(data, cb)
TriggerServerEvent("tgiann-mdtv2:olaysil", data.id)
end)
RegisterCommand(Config.KeyMapping..'mdtkeymapping', function()
TriggerEvent('tgiann-mdtv2:open')
end)
RegisterKeyMapping(Config.KeyMapping..'mdtkeymapping', lang[langSetting]["keyMappingHelp"], 'keyboard', Config.KeyMapping)
RegisterNetEvent("tgiann-mdtv2:open")
AddEventHandler("tgiann-mdtv2:open", function()
if PlayerData.job == nil then firstLogin() end
if PlayerData.job and PlayerData.job.name == "police" then
openClose()
end
end)
RegisterNUICallback('kapat', function(data, cb)
if nuiFocus then openClose() end
end)
AddEventHandler('onResourceStop', function(resourceName)
if (GetCurrentResourceName() == resourceName) then
if nuiFocus then openClose() end
end
end)
RegisterNUICallback('olayara', function(data, cb)
ESX.TriggerServerCallback("tgiann-mdtv2:olayara", function(result)
cb(result)
end, data.id)
end)
Citizen.CreateThread(function()
TriggerEvent('chat:addSuggestion', '/tabletzoom', lang[langSetting]["zoomSetting"], {{ name=lang[langSetting]["zoomSettingName"], help=lang[langSetting]["zoomSettingHelp"]}})
end)
RegisterCommand("tabletzoom", function(source, args)
if PlayerData.job and PlayerData.job.name == "police" then
if args[1] == nil then
local text = lang[langSetting]["zoomSettingNilError"]
if Config.Notify == 'esx' then
ESX.ShowNotification(text)
elseif Config.Notify == 'mythic' then
exports['mythic_notify']:SendAlert('error', text, 2500)
end
end
if tonumber(args[1]) < 50 then
local text = lang[langSetting]["zoomSettingMinError"]
if Config.Notify == 'esx' then
ESX.ShowNotification(text)
elseif Config.Notify == 'mythic' then
exports['mythic_notify']:SendAlert('error', text, 2500)
end
elseif tonumber(args[1]) > 100 then
local text = lang[langSetting]["zoomSettingMaxError"]
if Config.Notify == 'esx' then
ESX.ShowNotification(text)
elseif Config.Notify == 'mythic' then
exports['mythic_notify']:SendAlert('error', text, 2500)
end
else
local text = lang[langSetting]["zoomSettingConfirm"]
if Config.Notify == 'esx' then
ESX.ShowNotification(text)
elseif Config.Notify == 'mythic' then
exports['mythic_notify']:SendAlert('success', text, 2500)
end
SendNUIMessage({type = 'zoom', val = args[1]})
end
else
local text = lang[langSetting]["zoomSettingNotPolice"]
if Config.Notify == 'esx' then
ESX.ShowNotification(text)
elseif Config.Notify == 'mythic' then
exports['mythic_notify']:SendAlert('error', text, 2500)
end
end
end)