-
Notifications
You must be signed in to change notification settings - Fork 7
/
client.lua
390 lines (381 loc) · 20.1 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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
local veh = nil
local tesla_blip = nil
local tesla_pilot = false
local tesla_pilot_ped = nil
local tesla_dance = false
local pilot = false
local crash = false
local dance = false
local crash_ped_fl = nil
local crash_ped_fr = nil
local crash_ped_rl = nil
local crash_ped_rr = nil
--TriggerEvent('chat:addSuggestion', '/veh', 'car features', {{name="pilot|crash|dance|mark", help="Enable autopilot, crash-avoidance, Dance or mark your current vehicle "}})
RegisterCommand("veh", function(source, args)
if(args[1] == "mark") then
if(IsPedInAnyVehicle(GetPlayerPed(-1)) and GetPedInVehicleSeat(GetVehiclePedIsIn(GetPlayerPed(-1), false), -1) == GetPlayerPed(-1)) then
veh = GetVehiclePedIsIn(GetPlayerPed(-1), false)
minimap("This vehicle is now marked as your Vehicle.\nIt can be controlled when you are not sitting in it.")
if(DoesBlipExist(tesla_blip)) then
RemoveBlip(tesla_blip)
end
tesla_blip = AddBlipForEntity(veh)
SetBlipSprite(tesla_blip, 595)
SetBlipColour(tesla_blip, 26)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("Vehicle")
EndTextCommandSetBlipName(tesla_blip)
else
veh = nil
minimap("Your Vehicle has been unmarked.")
if(DoesBlipExist(tesla_blip)) then
RemoveBlip(tesla_blip)
end
tesla_blip = nil
end
else
if(IsPedInAnyVehicle(GetPlayerPed(-1), false) and GetPedInVehicleSeat(GetVehiclePedIsIn(GetPlayerPed(-1), false), -1) == GetPlayerPed(-1)) then
if(args[1] == "pilot") then
waypoint = Citizen.InvokeNative(0xFA7C7F0AADF25D09, GetFirstBlipInfoId(8), Citizen.ResultAsVector())
print(waypoint)
if(IsWaypointActive()) then
if(pilot) then
pilot = false
minimap("Auto-Pilot canceled.")
ClearPedTasks(GetPlayerPed(-1))
else
if(crash) then
crash = false
minimap("Crash-Avoidance deactivated.")
--DeletePed(crash_ped_fl)
DeleteEntity(crash_ped_fl)
--DeletePed(crash_ped_fr)
DeleteEntity(crash_ped_fr)
--DeletePed(crash_ped_front)
DeleteEntity(crash_ped_front)
--DeletePed(crash_ped_rear)
DeleteEntity(crash_ped_rear)
end
pilot = true
minimap("Auto-Pilot activated.")
TaskVehicleDriveToCoord(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), 0), waypoint["x"], waypoint["y"], waypoint["z"], 100.0, 1.0, GetHashKey(GetVehiclePedIsIn(GetPlayerPed(-1), 0)), 786603, 1.0, 1)
Citizen.CreateThread(function()
while pilot do
Wait(100)
if(GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1))["x"], GetEntityCoords(GetPlayerPed(-1))["y"], GetEntityCoords(GetPlayerPed(-1))["z"], waypoint["x"], waypoint["y"], waypoint["z"], 0) < 10.0) then
while GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), 0)) - 1.0 > 0.0 do
SetVehicleForwardSpeed(GetVehiclePedIsIn(GetPlayerPed(-1), 0), GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), 0)) - 1.0)
Wait(100)
end
pilot = false
ClearPedTasks(GetPlayerPed(-1))
minimap("Auto-Pilot deactivated.")
end
end
end)
end
else
minimap("No waypoint set.")
end
elseif(args[1] == "crash") then
if(crash) then
crash = false
minimap("Crash-Avoidance deactivated.")
--DeletePed(crash_ped_fl)
DeleteEntity(crash_ped_fl)
--DeletePed(crash_ped_fr)
DeleteEntity(crash_ped_fr)
--DeletePed(crash_ped_front)
DeleteEntity(crash_ped_front)
--DeletePed(crash_ped_rear)
DeleteEntity(crash_ped_rear)
elseif(pilot) then
minimap("Crash-Avoidance is disabled.")
else
RequestModel(225514697)
while not HasModelLoaded(225514697) do
Wait(5)
end
crash = true
minimap("Crash-Avoidance activated.")
crash_ped_fl = CreatePed(0, 225514697, GetEntityCoords(GetVehiclePedIsIn(GetPlayerPed(-1), 0))["x"], GetEntityCoords(GetVehiclePedIsIn(GetPlayerPed(-1), 0))["y"], GetEntityCoords(GetVehiclePedIsIn(GetPlayerPed(-1), 0))["z"], 0.0, false, true)
SetEntityInvincible(crash_ped_fl, true)
SetEntityVisible(crash_ped_fl, false, 0)
crash_ped_fr = CreatePed(0, 225514697, GetEntityCoords(GetVehiclePedIsIn(GetPlayerPed(-1), 0))["x"], GetEntityCoords(GetVehiclePedIsIn(GetPlayerPed(-1), 0))["y"], GetEntityCoords(GetVehiclePedIsIn(GetPlayerPed(-1), 0))["z"], 0.0, false, true)
SetEntityInvincible(crash_ped_fr, true)
SetEntityVisible(crash_ped_fr, false, 0)
crash_ped_front = CreatePed(0, 225514697, GetEntityCoords(GetVehiclePedIsIn(GetPlayerPed(-1), 0))["x"], GetEntityCoords(GetVehiclePedIsIn(GetPlayerPed(-1), 0))["y"], GetEntityCoords(GetVehiclePedIsIn(GetPlayerPed(-1), 0))["z"], 0.0, false, true)
SetEntityInvincible(crash_ped_front, true)
SetEntityVisible(crash_ped_front, false, 0)
crash_ped_rear = CreatePed(0, 225514697, GetEntityCoords(GetVehiclePedIsIn(GetPlayerPed(-1), 0))["x"], GetEntityCoords(GetVehiclePedIsIn(GetPlayerPed(-1), 0))["y"], GetEntityCoords(GetVehiclePedIsIn(GetPlayerPed(-1), 0))["z"], 0.0, false, true)
SetEntityInvincible(crash_ped_rear, true)
SetEntityVisible(crash_ped_rear, false, 0)
AttachEntityToEntity(crash_ped_rear, GetVehiclePedIsIn(GetPlayerPed(-1), false), GetEntityBoneIndexByName(GetVehiclePedIsIn(GetPlayerPed(-1), false), "boot"), 0.0, -1.8, 0.0, -90.0, 0.0, 0.0, false, false, false, true, 0, true)
Citizen.CreateThread(function()
while crash do
Wait(50)
DetachEntity(crash_ped_front, false, false)
DetachEntity(crash_ped_fl, false, false)
DetachEntity(crash_ped_fr, false, false)
if(GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false)) > 5.0) then
if(GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false)) < 16.0) then
AttachEntityToEntity(crash_ped_front, GetVehiclePedIsIn(GetPlayerPed(-1), false), GetEntityBoneIndexByName(GetVehiclePedIsIn(GetPlayerPed(-1), false), "bonnet"), 0.0, GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false)) / 2.0, 0.0, 90.0, 0.0, 0.0, false, false, false, true, 0, true)
AttachEntityToEntity(crash_ped_fl, GetVehiclePedIsIn(GetPlayerPed(-1), false), GetEntityBoneIndexByName(GetVehiclePedIsIn(GetPlayerPed(-1), false), "headlight_l"), -0.8, GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false)) / 5.0, 0.0, 50.0, 90.0, 0.0, false, false, false, true, 0, true)
AttachEntityToEntity(crash_ped_fr, GetVehiclePedIsIn(GetPlayerPed(-1), false), GetEntityBoneIndexByName(GetVehiclePedIsIn(GetPlayerPed(-1), false), "headlight_r"), 0.8, GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false)) / 5.0, 0.0, 50.0, -90.0, 0.0, false, false, false, true, 0, true)
else
AttachEntityToEntity(crash_ped_front, GetVehiclePedIsIn(GetPlayerPed(-1), false), GetEntityBoneIndexByName(GetVehiclePedIsIn(GetPlayerPed(-1), false), "bonnet"), 0.0, 8.0, 0.0, 90.0, 0.0, 0.0, false, false, false, true, 0, true)
AttachEntityToEntity(crash_ped_fl, GetVehiclePedIsIn(GetPlayerPed(-1), false), GetEntityBoneIndexByName(GetVehiclePedIsIn(GetPlayerPed(-1), false), "headlight_l"), -0.8, 3.0, 0.0, 50.0, 90.0, 0.0, false, false, false, true, 0, true)
AttachEntityToEntity(crash_ped_fr, GetVehiclePedIsIn(GetPlayerPed(-1), false), GetEntityBoneIndexByName(GetVehiclePedIsIn(GetPlayerPed(-1), false), "headlight_r"), 0.8, 3.0, 0.0, 50.0, -90.0, 0.0, false, false, false, true, 0, true)
end
else
AttachEntityToEntity(crash_ped_front, GetVehiclePedIsIn(GetPlayerPed(-1), false), GetEntityBoneIndexByName(GetVehiclePedIsIn(GetPlayerPed(-1), false), "bonnet"), 0.0, 3.5, 0.0, 90.0, 0.0, 0.0, false, false, false, true, 0, true)
AttachEntityToEntity(crash_ped_fl, GetVehiclePedIsIn(GetPlayerPed(-1), false), GetEntityBoneIndexByName(GetVehiclePedIsIn(GetPlayerPed(-1), false), "headlight_l"), -0.8, 0.7, 0.0, 50.0, 90.0, 0.0, false, false, false, true, 0, true)
AttachEntityToEntity(crash_ped_fr, GetVehiclePedIsIn(GetPlayerPed(-1), false), GetEntityBoneIndexByName(GetVehiclePedIsIn(GetPlayerPed(-1), false), "headlight_r"), 0.8, 0.7, 0.0, 50.0, -90.0, 0.0, false, false, false, true, 0, true)
end
if(IsPedInAnyVehicle(GetPlayerPed(-1), false)) then
if(IsAnyObjectNearPoint(GetEntityCoords(crash_ped_fl)["x"], GetEntityCoords(crash_ped_fl)["y"], GetEntityCoords(crash_ped_fl)["z"], 1.4, false)) then
if(GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false))) > 3.0 then
TaskVehicleTempAction(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 5, 45)
else
TaskVehicleTempAction(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 8, 45)
end
end
if(IsAnyVehicleNearPoint(GetEntityCoords(crash_ped_fl)["x"], GetEntityCoords(crash_ped_fl)["y"], GetEntityCoords(crash_ped_fl)["z"], 1.4)) then
if(GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false))) > 3.0 then
TaskVehicleTempAction(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 5, 45)
else
TaskVehicleTempAction(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 8, 45)
end
end
--[[if(IsAnyPedNearPoint(GetEntityCoords(crash_ped_fl)["x"], GetEntityCoords(crash_ped_fl)["y"], GetEntityCoords(crash_ped_fl)["z"], 1.4)) then
if(GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false))) > 3.0 then
TaskVehicleTempAction(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 5, 45)
else
TaskVehicleTempAction(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 8, 45)
end
end]]
if(IsAnyObjectNearPoint(GetEntityCoords(crash_ped_fr)["x"], GetEntityCoords(crash_ped_fr)["y"], GetEntityCoords(crash_ped_fr)["z"], 1.4, false)) then
if(GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false))) > 3.0 then
TaskVehicleTempAction(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 4, 45)
else
TaskVehicleTempAction(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 7, 45)
end
end
if(IsAnyVehicleNearPoint(GetEntityCoords(crash_ped_fr)["x"], GetEntityCoords(crash_ped_fr)["y"], GetEntityCoords(crash_ped_fr)["z"], 1.4)) then
if(GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false))) > 3.0 then
TaskVehicleTempAction(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 4, 45)
else
TaskVehicleTempAction(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 7, 45)
end
end
--[[if(IsAnyPedNearPoint(GetEntityCoords(crash_ped_fr)["x"], GetEntityCoords(crash_ped_fr)["y"], GetEntityCoords(crash_ped_fr)["z"], 1.4)) then
if(GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false))) > 3.0 then
TaskVehicleTempAction(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 4, 45)
else
TaskVehicleTempAction(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 7, 45)
end
end]]
if(IsAnyObjectNearPoint(GetEntityCoords(crash_ped_front)["x"], GetEntityCoords(crash_ped_front)["y"], GetEntityCoords(crash_ped_front)["z"], 3.0, false)) then
TaskVehicleTempAction(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 27, 45)
end
if(IsAnyVehicleNearPoint(GetEntityCoords(crash_ped_front)["x"], GetEntityCoords(crash_ped_front)["y"], GetEntityCoords(crash_ped_front)["z"], 3.0)) then
TaskVehicleTempAction(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 27, 45)
end
--[[if(IsAnyPedNearPoint(GetEntityCoords(crash_ped_front)["x"], GetEntityCoords(crash_ped_front)["y"], GetEntityCoords(crash_ped_front)["z"], 3.0)) then
TaskVehicleTempAction(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 27, 45)
end]]
if(IsAnyObjectNearPoint(GetEntityCoords(crash_ped_rear)["x"], GetEntityCoords(crash_ped_rear)["y"], GetEntityCoords(crash_ped_rear)["z"], 2.5, false)) then
TaskVehicleTempAction(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 23, 45)
end
if(IsAnyVehicleNearPoint(GetEntityCoords(crash_ped_rear)["x"], GetEntityCoords(crash_ped_rear)["y"], GetEntityCoords(crash_ped_rear)["z"], 2.5)) then
TaskVehicleTempAction(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 23, 45)
end
--[[if(IsAnyPedNearPoint(GetEntityCoords(crash_ped_rear)["x"], GetEntityCoords(crash_ped_rear)["y"], GetEntityCoords(crash_ped_rear)["z"], 2.5)) then
TaskVehicleTempAction(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 23, 45)
end]]
if(HasEntityBeenDamagedByAnyObject(GetVehiclePedIsIn(GetPlayerPed(-1), false)) or HasEntityBeenDamagedByAnyVehicle(GetVehiclePedIsIn(GetPlayerPed(-1), false))) then
crash = false
minimap("Crash Avoidance canceled.")
--DeletePed(crash_ped_fl)
DeleteEntity(crash_ped_fl)
--DeletePed(crash_ped_fr)
DeleteEntity(crash_ped_fr)
--DeletePed(crash_ped_front)
DeleteEntity(crash_ped_front)
--DeletePed(crash_ped_rear)
DeleteEntity(crash_ped_rear)
ClearEntityLastDamageEntity(GetVehiclePedIsIn(GetPlayerPed(-1), false))
end
else
crash = false
minimap("Crash-Avoidance deactivated.")
--DeletePed(crash_ped_fl)
DeleteEntity(crash_ped_fl)
--DeletePed(crash_ped_fr)
DeleteEntity(crash_ped_fr)
--DeletePed(crash_ped_front)
DeleteEntity(crash_ped_front)
--DeletePed(crash_ped_rear)
DeleteEntity(crash_ped_rear)
end
end
end)
end
elseif(args[1] == "dance") then
if(dance) then
dance = false
SetVehicleDoorsShut(GetVehiclePedIsIn(GetPlayerPed(-1), false), false)
minimap("Dance-Mode stopped.")
else
dance = true
minimap("Dance-Mode started.")
Citizen.CreateThread(function()
while dance do
Wait(100)
SetVehicleDoorOpen(GetVehiclePedIsIn(GetPlayerPed(-1), false), math.random(0, 6), false, false)
SetVehicleDoorShut(GetVehiclePedIsIn(GetPlayerPed(-1), false), math.random(0, 6), false)
end
end)
end
else
minimap("Unknown action.")
end
elseif(veh) then
if(args[1] == "pilot") then
if(tesla_pilot) then
if(tesla_pilot_ped) then
--DeletePed(tesla_pilot_ped)
RemovePedElegantly(tesla_pilot_ped)
end
tesla_pilot = false
tesla_pilot_ped = nil
SetVehicleEngineOn(veh, false, false, false)
minimap("Auto-Pilot canceled.")
else
RequestModel(225514697)
while not HasModelLoaded(225514697) do
Wait(5)
end
minimap("Auto-Pilot activated.")
tesla_pilot = true
tesla_pilot_ped = CreatePed(0, 225514697, GetEntityCoords(veh)["x"], GetEntityCoords(veh)["y"], GetEntityCoords(veh)["z"], 0.0, false, true)
SetPedIntoVehicle(tesla_pilot_ped, veh, -1)
SetEntityInvincible(tesla_pilot_ped, true)
SetEntityVisible(tesla_pilot_ped, false, 0)
player_coords = GetEntityCoords(GetPlayerPed(-1))
TaskVehicleDriveToCoord(tesla_pilot_ped, veh, player_coords.x, player_coords.y, player_coords.z, 100.0, 1.0, GetHashKey(veh), 786603, 1.0, 1)
Citizen.CreateThread(function()
while tesla_pilot do
Wait(100)
if(GetDistanceBetweenCoords(GetEntityCoords(veh)["x"], GetEntityCoords(veh)["y"], GetEntityCoords(veh)["z"], player_coords.x, player_coords.y, player_coords.z, 0) < 10.0) then
while GetEntitySpeed(veh) - 1.0 > 0.0 do
SetVehicleForwardSpeed(veh, GetEntitySpeed(veh) - 1.0)
Wait(100)
end
tesla_pilot = false
--DeletePed(tesla_pilot_ped)
RemovePedElegantly(tesla_pilot_ped)
tesla_pilot_ped = nil
SetVehicleEngineOn(veh, false, false, false)
minimap("Auto-Pilot deactivated.")
end
end
end)
end
elseif(args[1] == "dance") then
if(tesla_dance) then
tesla_dance = false
SetVehicleDoorsShut(veh, false)
minimap("Dance-Mode stopped.")
else
tesla_dance = true
minimap("Dance-Mode started.")
Citizen.CreateThread(function()
while tesla_dance do
Wait(100)
SetVehicleDoorOpen(veh, math.random(0, 6), false, false)
SetVehicleDoorShut(veh, math.random(0, 6), false)
end
end)
end
end
else
minimap("Unknown vehicle.")
end
end
end, false)
function minimap(text)
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
DrawNotification(0,1)
end
function translatespeed(float)
local speed = float + 11
return speed
end
autopilotenabled = false
Citizen.CreateThread(function()
while true do
local waypointBlip = GetFirstBlipInfoId(8) -- 8 = Waypoint ID
local x,y,z = table.unpack(Citizen.InvokeNative(0xFA7C7F0AADF25D09, waypointBlip, Citizen.ResultAsVector()))
local px,py,pz = table.unpack(GetEntityCoords(PlayerPedId()))
local distbetween = Vdist(x,y,z,px,py,pz)
if IsControlPressed(1,36) then
if IsControlJustPressed(1,21) then
if GetEntityModel(GetVehiclePedIsUsing(PlayerPedId())) == -1894894188 or GetEntityModel(GetVehiclePedIsUsing(PlayerPedId())) == -429774847 or GetEntityModel(GetVehiclePedIsUsing(PlayerPedId())) == -1622444098 or GetEntityModel(GetVehiclePedIsUsing(PlayerPedId())) == 884483972 or GetEntityModel(GetVehiclePedIsUsing(PlayerPedId())) == 569305213 or GetEntityModel(GetVehiclePedIsUsing(PlayerPedId())) == -1285460620 or GetEntityModel(GetVehiclePedIsUsing(PlayerPedId())) == -1529242755 or GetEntityModel(GetVehiclePedIsUsing(PlayerPedId())) == -429774847 then
autopilotenabled = not autopilotenabled
if autopilotenabled then
SetNotificationTextEntry("STRING")
AddTextComponentString("~y~Autopilot ~g~Engaged")
DrawNotification(false, true)
if(not IsWaypointActive())then
SetNotificationTextEntry("STRING")
AddTextComponentString("~r~ERROR:~w~ No Destination Set.")
DrawNotification(true, true)
autopilotenabled = false
SetNotificationTextEntry("STRING")
AddTextComponentString("~y~Autopilot ~r~Deactivated")
DrawNotification(true, true)
TaskPause(PlayerPedId(), 10)
else
defaultspeed = 20.0 --1 = 3 MPH 5 = 11 MPH
TaskVehicleDriveToCoordLongrange(PlayerPedId(),GetVehiclePedIsUsing(PlayerPedId()), x,y,z, defaultspeed, 262579, 1.0) --262579
end
else
SetNotificationTextEntry("STRING")
AddTextComponentString("~y~Autopilot ~r~Deactivated")
DrawNotification(false, true)
TaskPause(PlayerPedId(), 10)
end
else
SetNotificationTextEntry("STRING")
AddTextComponentString("This Vehicle is not equipped with ~y~Autopilot~w~!")
DrawNotification(false, true)
end
end
end
if autopilotenabled then
if IsControlJustPressed(0, 71) and GetLastInputMethod( 0 ) then
defaultspeed = defaultspeed + 1.0
TaskVehicleDriveToCoordLongrange(PlayerPedId(),GetVehiclePedIsUsing(PlayerPedId()), x,y,z, defaultspeed, 262579, 1.0)
end
if IsControlJustPressed(0,72) and GetLastInputMethod( 0 ) then
defaultspeed = defaultspeed - 1.0
TaskVehicleDriveToCoordLongrange(PlayerPedId(),GetVehiclePedIsUsing(PlayerPedId()), x,y,z, defaultspeed, 262579, 1.0)
end
if IsControlJustPressed(0,76) and GetLastInputMethod( 0 ) then
defaultspeed = 0.0
TaskVehicleDriveToCoordLongrange(PlayerPedId(),GetVehiclePedIsUsing(PlayerPedId()), x,y,z, defaultspeed, 262579, 1.0)
SetNotificationTextEntry("STRING")
AddTextComponentString("~y~[Autopilot]~r~ Emergency Stop Engaged")
DrawNotification(true, true)
SetNotificationTextEntry("STRING")
AddTextComponentString("~y~Autopilot ~r~Deactivated")
DrawNotification(false, true)
TaskPause(PlayerPedId(), 10)
autopilotenabled = false
end
end
Citizen.Wait(0)
end
end)