-
Notifications
You must be signed in to change notification settings - Fork 2
/
client.lua
126 lines (112 loc) · 4 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
--[[
Copyright (C) 2021-2022 Sub-Zero Interactive
All rights reserved.
Permission is hereby granted, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software with 'All rights reserved'. Even if 'All rights reserved' is very clear :
You shall not sell and/or resell this software
The rights to use, modify and merge
The above copyright notice and this permission notice shall be included in all copies and files of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
--]]
ESX = nil
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
while ESX.GetPlayerData().job == nil do
Citizen.Wait(10)
end
ESX.PlayerData = ESX.GetPlayerData()
end)
RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
ESX.PlayerData.job = job
end)
local tint = nil
local display = false
RegisterCommand("checktint", function()
if ESX.PlayerData.job and ESX.PlayerData.job.name == 'police' then
local vehicle, distance = ESX.Game.GetClosestVehicle()
if vehicle and distance <= 5 then
SetDisplay(true)
if GetVehicleWindowTint(vehicle) == -1 then
SendNUIMessage({
type = "data",
tint = 'None',
textColor = '--color-black'
})
elseif GetVehicleWindowTint(vehicle) == 0 then
SendNUIMessage({
type = "data",
tint = 'Stock',
textColor = '--color-black'
})
elseif GetVehicleWindowTint(vehicle) == 1 then
SendNUIMessage({
type = "data",
tint = 'Pure Black',
textColor = '--color-red'
})
elseif GetVehicleWindowTint(vehicle) == 2 then
SendNUIMessage({
type = "data",
tint = 'Dark Smoke',
textColor = '--color-red'
})
elseif GetVehicleWindowTint(vehicle) == 3 then
SendNUIMessage({
type = "data",
tint = 'Light Smoke',
textColor = '--color-black'
})
elseif GetVehicleWindowTint(vehicle) == 4 then
SendNUIMessage({
type = "data",
tint = 'Limo',
textColor = '--color-black'
})
elseif GetVehicleWindowTint(vehicle) == 5 then
SendNUIMessage({
type = "data",
tint = 'Green',
textColor = '--color-black'
})
end
else
ESX.ShowNotification("No Vehicle Nearby")
end
FreezeEntityPosition(PlayerPedId(), false)
end
end, false)
function SetDisplay(bool)
display = bool
SetNuiFocus(bool, bool)
SendNUIMessage({
type = "ui",
status = bool,
})
end
RegisterNUICallback("exit", function(data)
SetDisplay(false)
SendNUIMessage({
type = "data",
tint = 'None',
textColor = '--color-black'
})
end)
RegisterNetEvent('szi_windowtint:displayTint')
AddEventHandler('szi_windowtint:displayTint', function(tint, color)
SendNUIMessage({
type = "data",
tint = tint,
textColor = color
})
end)