-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcl_functions.lua
290 lines (254 loc) · 11.2 KB
/
cl_functions.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
function CenterText(msg, time) ClearPrints() BeginTextCommandPrint('STRING') AddTextComponentSubstringPlayerName(msg) EndTextCommandPrint(time, 1) end
function Mugshot(title, subject, msg, player) local mugshot, mugshotStr = ESX.Game.GetPedMugshot(player) AdvancedNotif(title, subject, msg, mugshotStr, 1) UnregisterPedheadshot(mugshot) end
function Notif(msg) SetNotificationTextEntry('STRING') AddTextComponentSubstringPlayerName(msg) DrawNotification(false, true) end
function AdvancedNotif(title, subject, msg, icon, iconType) SetNotificationTextEntry('STRING') AddTextComponentSubstringPlayerName(msg) SetNotificationMessage(icon, icon, false, iconType, title, subject) DrawNotification(false, false) end
function PlayerMarqueur(player) local ped = GetPlayerPed(player) local pos = GetEntityCoords(ped) DrawMarker(2, pos.x, pos.y, pos.z+1.3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.2, 0.2, 0.2, 255, 255, 255, 170, 1, 1, 2, 0, nil, nil, 0) end
RegisterNetEvent("dakom:advancednotif") AddEventHandler("dakom:advancednotif", function(title, subject, msg, icon, iconType) AdvancedNotif(title, subject, msg, icon, iconType) end)
RegisterNetEvent("dakom:notif") AddEventHandler("dakom:notif", function(msg) Notif(msg) end)
RegisterNetEvent("dakom:mughshotnotif") AddEventHandler("dakom:mughshotnotif", function(title, subject, msg, player) Mugshot(title, subject, msg, player) end)
function TeleportBlips()
local entity = PlayerPedId()
if IsPedInAnyVehicle(entity, false) then
entity = GetVehiclePedIsUsing(entity)
end
local success = false
local blipFound = false
local blipIterator = GetBlipInfoIdIterator()
local blip = GetFirstBlipInfoId(8)
while DoesBlipExist(blip) do
if GetBlipInfoIdType(blip) == 4 then
cx, cy, cz = table.unpack(Citizen.InvokeNative(0xFA7C7F0AADF25D09, blip, Citizen.ReturnResultAnyway(), Citizen.ResultAsVector()))
blipFound = true
break
end
blip = GetNextBlipInfoId(blipIterator)
Wait(0)
end
if blipFound then
local groundFound = false
local yaw = GetEntityHeading(entity)
for i = 0, 1000, 1 do
SetEntityCoordsNoOffset(entity, cx, cy, ToFloat(i), false, false, false)
SetEntityRotation(entity, 0, 0, 0, 0, 0)
SetEntityHeading(entity, yaw)
Wait(0)
if GetGroundZFor_3dCoord(cx, cy, ToFloat(i), cz, false) then
cz = ToFloat(i)
groundFound = true
break
end
end
if not groundFound then
cz = -300.0
end
success = true
else
Notif(iAdmin.Nomarkeroffset)
end
if success then
SetEntityCoordsNoOffset(entity, cx, cy, cz, false, false, true)
if IsPedSittingInAnyVehicle(PlayerPedId()) then
if GetPedInVehicleSeat(GetVehiclePedIsUsing(PlayerPedId()), -1) == PlayerPedId() then
SetVehicleOnGroundProperly(GetVehiclePedIsUsing(PlayerPedId()))
end
end
end
end
function SupprVehicle()
local pos = GetEntityCoords(PlayerPedId())
local veh = ESX.Game.GetClosestVehicle({x = pos.x, y = pos.y, z = pos.z})
pos = GetEntityCoords(veh)
local _, distance = ESX.Game.GetClosestVehicle()
if distance <= 2.0 then
local pPed = PlayerPedId()
if IsPedInAnyVehicle(pPed, false) then
local pVeh = GetVehiclePedIsIn(pPed, false)
TaskLeaveAnyVehicle(pPed, 1, 1)
Wait(2500)
while IsPedInAnyVehicle(pPed, false) do
TaskLeaveAnyVehicle(pPed, 1, 1)
Wait(200)
end
DeleteEntity(pVeh)
else
Notif("~b~Police\n~r~Tu dois rentrer dans le véhicule~s~")
end
else
Notif("~b~Admin\n~r~Aucun véhicule a proximité~s~")
end
end
local function BoardAdminD(entryTitle, textEntry, inputText, maxLength)
AddTextEntry(entryTitle, textEntry)
DisplayOnscreenKeyboard(1, entryTitle, '', inputText, '', '', '', maxLength)
blockinput = true
while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do
Wait(0)
end
if UpdateOnscreenKeyboard() ~= 2 then
local result = GetOnscreenKeyboardResult()
Wait(500)
blockinput = false
return result
else
Wait(500)
blockinput = false
return nil
end
end
function SpawnVeh()
if IsPedInAnyVehicle(PlayerPedId(), -1) then
Notif("~r~Veuillez sortir du véhicule pour effectuer cette action !")
else
local vehicleName = BoardAdminD("DAKOM_BOX_VEHICLE_NAME", 'Nom du véhicule', "", 15)
if vehicleName ~= nil then
vehicleName = tostring(vehicleName)
if type(vehicleName) == 'string' then
local cardako = GetHashKey(vehicleName)
CreateThread(function()
RequestModel(cardako)
while not HasModelLoaded(cardako) do
Wait(0)
end
local x, y, z = table.unpack(GetEntityCoords(PlayerPedId(), true))
local veh = CreateVehicle(cardako, x, y, z, 0.0, true, false)
SetVehicleOnGroundProperly(veh)
SetVehicleHasBeenOwnedByPlayer(veh, true)
SetPedIntoVehicle(PlayerPedId(), veh, -1)
end)
end
end
end
end
local function ButtonMessage(text)
BeginTextCommandScaleformString("STRING")
AddTextComponentScaleform(text)
EndTextCommandScaleformString()
end
local function Button(ControlButton)
N_0xe83a3e3557a56640(ControlButton)
end
local function setupScaleform(scaleform)
local scaleform = RequestScaleformMovie(scaleform)
while not HasScaleformMovieLoaded(scaleform) do
Wait(1)
end
PushScaleformMovieFunction(scaleform, "CLEAR_ALL")
PopScaleformMovieFunctionVoid()
PushScaleformMovieFunction(scaleform, "SET_CLEAR_SPACE")
PushScaleformMovieFunctionParameterInt(200)
PopScaleformMovieFunctionVoid()
PushScaleformMovieFunction(scaleform, "SET_DATA_SLOT")
PushScaleformMovieFunctionParameterInt(4)
Button(GetControlInstructionalButton(2, iAdmin.goUp, true))
ButtonMessage(iAdmin.UpNoclip)
PopScaleformMovieFunctionVoid()
PushScaleformMovieFunction(scaleform, "SET_DATA_SLOT")
PushScaleformMovieFunctionParameterInt(3)
Button(GetControlInstructionalButton(2, iAdmin.goDown, true))
ButtonMessage(iAdmin.DownNoclip)
PopScaleformMovieFunctionVoid()
PushScaleformMovieFunction(scaleform, "SET_DATA_SLOT")
PushScaleformMovieFunctionParameterInt(2)
Button(GetControlInstructionalButton(1, iAdmin.turnRight, true))
Button(GetControlInstructionalButton(1, iAdmin.turnLeft, true))
ButtonMessage(iAdmin.LeftRightNoclip)
PopScaleformMovieFunctionVoid()
PushScaleformMovieFunction(scaleform, "SET_DATA_SLOT")
PushScaleformMovieFunctionParameterInt(1)
Button(GetControlInstructionalButton(1, iAdmin.goBackward, true))
Button(GetControlInstructionalButton(1, iAdmin.goForward, true))
ButtonMessage(iAdmin.ForwardsNoclip)
PopScaleformMovieFunctionVoid()
PushScaleformMovieFunction(scaleform, "SET_DATA_SLOT")
PushScaleformMovieFunctionParameterInt(0)
Button(GetControlInstructionalButton(2, iAdmin.changeSpeed, true))
ButtonMessage(iAdmin.SpeedTextNoclip.. " ("..iAdmin.speeds[index].label..")")
PopScaleformMovieFunctionVoid()
PushScaleformMovieFunction(scaleform, "DRAW_INSTRUCTIONAL_BUTTONS")
PopScaleformMovieFunctionVoid()
PushScaleformMovieFunction(scaleform, "SET_BACKGROUND_COLOUR")
PushScaleformMovieFunctionParameterInt(0)
PushScaleformMovieFunctionParameterInt(0)
PushScaleformMovieFunctionParameterInt(0)
PushScaleformMovieFunctionParameterInt(40)
PopScaleformMovieFunctionVoid()
return scaleform
end
noclipActive = false
index = 1
CreateThread(function()
buttons = setupScaleform("instructional_buttons")
currentSpeed = iAdmin.speeds[index].speed
while true do
Wait(1)
if noclipActive then
DrawScaleformMovieFullscreen(buttons)
local yoff = 0.0
local zoff = 0.0
if IsControlJustPressed(1, iAdmin.changeSpeed) then
if index ~= 8 then
index = index+1
currentSpeed = iAdmin.speeds[index].speed
else
currentSpeed = iAdmin.speeds[1].speed
index = 1
end
setupScaleform("instructional_buttons")
end
if IsControlPressed(0, iAdmin.goForward) then
yoff = configs.offsets.y
end
if IsControlPressed(0, iAdmin.goBackward) then
yoff = -configs.offsets.y
end
if IsControlPressed(0, iAdmin.turnLeft) then
SetEntityHeading(noclipEntity, GetEntityHeading(noclipEntity)+configs.offsets.h)
end
if IsControlPressed(0, iAdmin.turnRight) then
SetEntityHeading(noclipEntity, GetEntityHeading(noclipEntity)-configs.offsets.h)
end
if IsControlPressed(0, iAdmin.goUp) then
zoff = configs.offsets.z
end
if IsControlPressed(0, iAdmin.goDown) then
zoff = -configs.offsets.z
end
local newPos = GetOffsetFromEntityInWorldCoords(noclipEntity, 0.0, yoff * (currentSpeed + 0.3), zoff * (currentSpeed + 0.3))
local heading = GetEntityHeading(noclipEntity)
SetEntityVelocity(noclipEntity, 0.0, 0.0, 0.0)
SetEntityRotation(noclipEntity, 0.0, 0.0, 0.0, 0, false)
SetEntityHeading(noclipEntity, heading)
SetEntityCoordsNoOffset(noclipEntity, newPos.x, newPos.y, newPos.z, noclipActive, noclipActive, noclipActive)
end
end
end)
configs = {
offsets = {
y = 0.4,
z = 0.2,
h = 3,
},
}
function MarkerVehicle()
local pos = GetEntityCoords(PlayerPedId())
local veh, dst = ESX.Game.GetClosestVehicle({x = pos.x, y = pos.y, z = pos.z})
local pos = GetEntityCoords(veh)
local _, distance = ESX.Game.GetClosestVehicle()
if distance <= 5.0 then
DrawMarker(2, pos.x, pos.y, pos.z+1.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.2, 0.2, 0.2, iAdmin.ColorMarkVeh.R, iAdmin.ColorMarkVeh.G, iAdmin.ColorMarkVeh.B, iAdmin.ColorMarkVeh.A, 0, 1, 2, 1, nil, nil, 0)
end
end
function SpectatePlayer(targetPed,target)
local playerPed = PlayerPedId()
enable = true
if targetPed == playerPed then enable = false end
if enable then
local targetx,targety,targetz = table.unpack(GetEntityCoords(targetPed, false))
RequestCollisionAtCoord(targetx,targety,targetz)
NetworkSetInSpectatorMode(true, targetPed)
else
local targetx,targety,targetz = table.unpack(GetEntityCoords(targetPed, false))
RequestCollisionAtCoord(targetx,targety,targetz)
NetworkSetInSpectatorMode(false, targetPed)
end
end