-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathclient.lua
More file actions
227 lines (187 loc) · 7.79 KB
/
client.lua
File metadata and controls
227 lines (187 loc) · 7.79 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
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
local ESX = nil
local allLicensesClient = {}
local mylicenseClient = {}
local lSelected = {}
local indexMenu = 1
local TypeDispo = {
[1] = 'drive',
[2] = 'drive_bike',
[3] = 'drive_truck'
}
Citizen.CreateThread(function()
TriggerEvent('esx:getSharedObject', function(lib) ESX = lib end)
while ESX == nil do Citizen.Wait(100) end
while ESX.GetPlayerData().job == nil do
Citizen.Wait(10)
end
ESX.PlayerData = ESX.GetPlayerData()
end)
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
ESX.PlayerData = xPlayer
end)
RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
ESX.PlayerData.job = job
end)
local function KeyboardInput(TextEntry, ExampleText, MaxStringLenght)
AddTextEntry('FMMC_KEY_TIP1', TextEntry)
DisplayOnscreenKeyboard(1, "FMMC_KEY_TIP1", "", ExampleText, "", "", "", MaxStringLenght)
blockinput = true
while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do
Citizen.Wait(0)
end
if UpdateOnscreenKeyboard() ~= 2 then
local result = GetOnscreenKeyboardResult()
Citizen.Wait(500)
blockinput = false
return result
else
Citizen.Wait(500)
blockinput = false
return nil
end
end
local function menuPointLicenses()
local menuP = RageUI.CreateMenu("Gestions Permis", ' ')
local menuS = RageUI.CreateSubMenu(menuP, "Gestions Permis", ' ')
menuP:SetRectangleBanner(11, 11, 11, 1)
menuS:SetRectangleBanner(11, 11, 11, 1)
RageUI.Visible(menuP, not RageUI.Visible(menuP))
while menuP do
Citizen.Wait(0)
RageUI.IsVisible(menuP, true, true, true, function()
if Config.permisdecision == true then
for k,v in pairs(allLicensesClient) do
if v.Type == TypeDispo[1] then
RageUI.ButtonWithStyle("Nom : "..v.Name, nil, {RightLabel = "→→"}, true, function(Hovered, Active, Selected)
if Selected then
lSelected = v
end
end, menuS)
end
end
else
RageUI.List('Type de permis : ', {'Voiture', 'Moto', 'Camion'}, indexMenu, nil, {}, true, function(Hovered, Active, Selected, Index)
indexMenu = Index
end)
for k,v in pairs(allLicensesClient) do
if v.Type == TypeDispo[indexMenu] then
RageUI.ButtonWithStyle(v.Name, nil, {RightLabel = v.Point.." Point(s)"}, true, function(Hovered, Active, Selected)
if Selected then
lSelected = v
end
end, menuS)
end
end
end
end)
RageUI.IsVisible(menuS, true, true, true, function()
RageUI.Separator(lSelected.Name.." - "..lSelected.Point.. " Point(s)")
if Config.permisdecision == true then
RageUI.ButtonWithStyle("Ajouter des points", nil, {RightLabel = "→"}, true, function(Hovered, Active, Selected)
if Selected then
local qty = KeyboardInput("Combien de points voulez-vous ajouter ? ", "", 3)
TriggerServerEvent('rPermisPoint:addPoint', TypeDispo[1], qty, lSelected.Owner)
TriggerServerEvent('rPermisPoint:addPoint', TypeDispo[2], qty, lSelected.Owner)
TriggerServerEvent('rPermisPoint:addPoint', TypeDispo[3], qty, lSelected.Owner)
RageUI.CloseAll()
end
end)
RageUI.ButtonWithStyle("Retirer des points", nil, {RightLabel = "→"}, true, function(Hovered, Active, Selected)
if Selected then
local qty = KeyboardInput("Combien de points voulez-vous retirer ? ", "", 3)
TriggerServerEvent('rPermisPoint:removePoint', TypeDispo[1], qty, lSelected.Owner)
TriggerServerEvent('rPermisPoint:removePoint', TypeDispo[2], qty, lSelected.Owner)
TriggerServerEvent('rPermisPoint:removePoint', TypeDispo[3], qty, lSelected.Owner)
RageUI.CloseAll()
end
end)
else
RageUI.ButtonWithStyle("Ajouter des points", nil, {RightLabel = "→"}, true, function(Hovered, Active, Selected)
if Selected then
local qty = KeyboardInput("Combien de points voulez-vous ajouter ? ", "", 3)
TriggerServerEvent('rPermisPoint:addPoint', lSelected.Type, qty, lSelected.Owner)
RageUI.CloseAll()
end
end)
RageUI.ButtonWithStyle("Retirer des points", nil, {RightLabel = "→"}, true, function(Hovered, Active, Selected)
if Selected then
local qty = KeyboardInput("Combien de points voulez-vous retirer ? ", "", 3)
TriggerServerEvent('rPermisPoint:removePoint', lSelected.Type, qty, lSelected.Owner)
RageUI.CloseAll()
end
end)
end
end)
if not RageUI.Visible(menuP) and not RageUI.Visible(menuS) then
menuP = RMenu:DeleteType("Menu Point", true)
end
end
end
local function mespoints()
local MenuMp = RageUI.CreateMenu("Mes Point(s)", ' ')
MenuMp:SetRectangleBanner(11, 11, 11, 1)
RageUI.Visible(MenuMp, not RageUI.Visible(MenuMp))
while MenuMp do
Citizen.Wait(0)
RageUI.IsVisible(MenuMp, true, true, true, function()
if Config.permisdecision == true then
for k,v in pairs(mylicenseClient) do
if v.Type == TypeDispo[1] then
RageUI.Separator("Vous avez actuellement : "..v.Point.." points sur votre permis")
end
end
else
for k,v in pairs(mylicenseClient) do
if v.Type == TypeDispo[indexMenu] then
RageUI.Separator("Vous avez actuellement : "..v.Point.." points sur votre permis")
end
end
RageUI.List('Type de permis : ', {'Voiture', 'Moto', 'Camion'}, indexMenu, nil, {}, true, function(Hovered, Active, Selected, Index)
indexMenu = Index
end)
end
end)
if not RageUI.Visible(MenuMp) and not RageUI.Visible(menuS) then
MenuMp = RMenu:DeleteType("Menu Point", true)
end
end
end
Citizen.CreateThread(function()
while true do
local Timer = 500
local plyPos = GetEntityCoords(PlayerPedId())
for k,v in pairs(Config.menuPermisInfo) do
if ESX.PlayerData.job and ESX.PlayerData.job.name == v.jobName then
local dist = #(plyPos-v.posMenu)
if dist <= 10.0 then
Timer = 0
DrawMarker(22, v.posMenu, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0.45, 0.45, 0.45, 255, 0, 0, 255, 55555, false, true, 2, false, false, false, false)
end
if dist <= 3.0 then
Timer = 0
RageUI.Text({ message = "Appuyez sur ~y~[E]~s~ pour accéder à la gestion des permis", time_display = 1 })
if IsControlJustPressed(1,51) then
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
if closestPlayer ~= -1 and closestDistance <= 3.0 then
ESX.TriggerServerCallback('rPermisPoint:getAllLicenses', function(result)
allLicensesClient = result
menuPointLicenses()
end, GetPlayerServerId(closestPlayer))
else
ESX.ShowNotification('Aucun joueurs à proximité')
end
end
end
end
end
Citizen.Wait(Timer)
end
end)
RegisterCommand(Config.cmdplayer, function()
ESX.TriggerServerCallback('rPermisPoint:getLicenses', function(result)
mylicenseClient = result
mespoints()
end)
end)