-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.lua
311 lines (299 loc) · 13.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
--- Script by Neotastisch
local vehicles = "" -- let empty
local tesla = nil
local tesla_blip = nil
local tesla_pilot = false
local tesla_pilot_ped = nil
local pilot = false
local dance = false
local lines = false
TriggerEvent('chat:addSuggestion', '/autopilot', 'Autopilot features', {{name="toggle|mark|waypoint|follow", help="Activate Autopilot"}})
RegisterCommand("autopilot", function(source, args)
if(args[1] == "author") then
minimap("The author is Neotastisch")
end
if(args[1] == "waypoint") then
if(tesla_pilot) then
if(tesla_pilot_ped) then
RemovePedElegantly(tesla_pilot_ped)
end
tesla_pilot = false
tesla_pilot_ped = nil
SetVehicleEngineOn(tesla, false, false, false)
minimap("Auto-Pilot deactivated.")
else
RequestModel(225514697)
while not HasModelLoaded(225514697) do
Wait(5)
end
for i = 0, 6 do
SetVehicleDoorShut(tesla, i, false) -- will close all doors from 0-6
end
minimap("Auto-Pilot activated.")
tesla_pilot = true
tesla_pilot_ped = CreatePed(0, 225514697, GetEntityCoords(tesla)["x"], GetEntityCoords(tesla)["y"], GetEntityCoords(tesla)["z"], 0.0, false, true)
SetEntityAsMissionEntity(tesla_pilot_ped, true, true)
SetPedIntoVehicle(tesla_pilot_ped, tesla, -1)
SetEntityInvincible(tesla_pilot_ped, true)
SetEntityVisible(tesla_pilot_ped, false, 0)
waypoint = Citizen.InvokeNative(0xFA7C7F0AADF25D09, GetFirstBlipInfoId(8), Citizen.ResultAsVector())
TaskVehicleDriveToCoord(tesla_pilot_ped, tesla, waypoint["x"], waypoint["y"], waypoint["z"], 25.0, 0.0, GetHashKey(tesla), 795452, 1.0, 1)
Citizen.CreateThread(function()
while tesla_pilot do
Wait(100)
if(GetDistanceBetweenCoords(GetEntityCoords(tesla)["x"], GetEntityCoords(tesla)["y"], GetEntityCoords(tesla)["z"], waypoint["x"], waypoint["y"], waypoint["z"], 0) < 10.0) then
while GetEntitySpeed(tesla) - 1.0 > 0.0 do
SetVehicleForwardSpeed(tesla, GetEntitySpeed(tesla) - 1.0)
Wait(100)
end
tesla_pilot = false
RemovePedElegantly(tesla_pilot_ped)
tesla_pilot_ped = nil
SetVehicleEngineOn(tesla, false, false, false)
minimap("Auto-Pilot arrived.")
end
end
end)
end
return
end
if(args[1] == "follow") then
if(tesla_pilot) then
if(tesla_pilot_ped) then
RemovePedElegantly(tesla_pilot_ped)
end
tesla_pilot = false
tesla_pilot_ped = nil
SetVehicleEngineOn(tesla, false, false, false)
minimap("Auto-Pilot deactivated.")
else
RequestModel(225514697)
while not HasModelLoaded(225514697) do
Wait(5)
end
for i = 0, 6 do
SetVehicleDoorShut(tesla, i, false) -- will close all doors from 0-6
end
minimap("Auto-Pilot activated.")
tesla_pilot = true
tesla_pilot_ped = CreatePed(0, 225514697, GetEntityCoords(tesla)["x"], GetEntityCoords(tesla)["y"], GetEntityCoords(tesla)["z"], 0.0, false, true)
SetEntityAsMissionEntity(tesla_pilot_ped, true, true)
SetPedIntoVehicle(tesla_pilot_ped, tesla, -1)
SetEntityInvincible(tesla_pilot_ped, true)
SetEntityVisible(tesla_pilot_ped, false, 0)
Citizen.CreateThread(function()
while tesla_pilot do
Wait(1000)
player_coords = GetEntityCoords(GetPlayerPed(-1))
speed = GetEntitySpeed(GetPlayerPed(-1));
if(speed > 1)then speed = 19 end
TaskVehicleDriveToCoord(tesla_pilot_ped, tesla, player_coords.x, player_coords.y, player_coords.z, speed+8, 0.0, GetHashKey(tesla), 525116, 1.0, 1)
end
end)
end
return
end
--
if(args[1] == "dance") then
if(dance) then
dance = false
SetVehicleDoorsShut(GetVehiclePedIsIn(GetPlayerPed(-1), false), false)
minimap("Dance mode stopped.")
for i = 0, 6 do
SetVehicleDoorShut(tesla, i, false) -- will close all doors from 0-6
end
return
else
dance = true
minimap("Dance mode started.")
Citizen.CreateThread(function()
SetVehRadioStation(GetVehiclePedIsIn(GetPlayerPed(-1), false), 'OFF')
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)
return
end
end
if(args[1] == "taxi") then
minimap("Set as nearest vehicle")
local pos = GetEntityCoords(GetPlayerPed(-1),true)
local veh = GetClosestVehicle(pos.x,pos.y,pos.z,100000.00,0)
if IsEntityAVehicle(veh) then
tesla = veh
SetEntityAsMissionEntity(veh, true, true)
TaskVehicleDriveToCoord(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), 0), waypoint["x"], waypoint["y"], waypoint["z"], 30.0, 0.0, GetHashKey(GetVehiclePedIsIn(GetPlayerPed(-1), 0)), 525116, 0, true)
return
else
minimap("No vehicles in distance.")
return
end
end
if(args[1] == "lines") then
if(lines) then
minimap("Reverse lines deactivated.")
lines = false
else
minimap("Reverse lines activated.")
lines = true
Citizen.CreateThread(function()
while lines do
Wait(5)
if(IsPedInAnyVehicle(GetPlayerPed(-1)) and GetPedInVehicleSeat(GetVehiclePedIsIn(GetPlayerPed(-1), false), -1) == GetPlayerPed(-1)) then
if(GetVehicleCurrentGear(GetVehiclePedIsIn(GetPlayerPed(-1), false)) == 0) then
DrawLine(GetOffsetFromEntityInWorldCoords(GetVehiclePedIsIn(GetPlayerPed(-1), false), 1.0, -2.0, 0.0).x, GetOffsetFromEntityInWorldCoords(GetVehiclePedIsIn(GetPlayerPed(-1), false), 1.0, -2.0, 0.0).y, GetOffsetFromEntityInWorldCoords(GetVehiclePedIsIn(GetPlayerPed(-1), false), 1.0, -2.0, 0.0).z, GetOffsetFromEntityInWorldCoords(GetVehiclePedIsIn(GetPlayerPed(-1), false), 1.0 - (GetVehicleSteeringAngle(GetVehiclePedIsIn(GetPlayerPed(-1), false)) / GetVehicleHandlingFloat(GetVehiclePedIsIn(GetPlayerPed(-1), false), "CHandlingData", "fSteeringLock")), -6.0, 0.0).x, GetOffsetFromEntityInWorldCoords(GetVehiclePedIsIn(GetPlayerPed(-1), false), 1.0 - (GetVehicleSteeringAngle(GetVehiclePedIsIn(GetPlayerPed(-1), false)) / GetVehicleHandlingFloat(GetVehiclePedIsIn(GetPlayerPed(-1), false), "CHandlingData", "fSteeringLock")), -6.0, 0.0).y, GetOffsetFromEntityInWorldCoords(GetVehiclePedIsIn(GetPlayerPed(-1), false), 1.0 - (GetVehicleSteeringAngle(GetVehiclePedIsIn(GetPlayerPed(-1), false)) / GetVehicleHandlingFloat(GetVehiclePedIsIn(GetPlayerPed(-1), false), "CHandlingData", "fSteeringLock")), -6.0, 0.0).z, 255, 255, 255, 255)
DrawLine(GetOffsetFromEntityInWorldCoords(GetVehiclePedIsIn(GetPlayerPed(-1), false), -1.0, -2.0, 0.0).x, GetOffsetFromEntityInWorldCoords(GetVehiclePedIsIn(GetPlayerPed(-1), false), -1.0, -2.0, 0.0).y, GetOffsetFromEntityInWorldCoords(GetVehiclePedIsIn(GetPlayerPed(-1), false), -1.0, -2.0, 0.0).z, GetOffsetFromEntityInWorldCoords(GetVehiclePedIsIn(GetPlayerPed(-1), false), -1.0 - (GetVehicleSteeringAngle(GetVehiclePedIsIn(GetPlayerPed(-1), false)) / GetVehicleHandlingFloat(GetVehiclePedIsIn(GetPlayerPed(-1), false), "CHandlingData", "fSteeringLock")), -6.0, 0.0).x, GetOffsetFromEntityInWorldCoords(GetVehiclePedIsIn(GetPlayerPed(-1), false), -1.0 - (GetVehicleSteeringAngle(GetVehiclePedIsIn(GetPlayerPed(-1), false)) / GetVehicleHandlingFloat(GetVehiclePedIsIn(GetPlayerPed(-1), false), "CHandlingData", "fSteeringLock")), -6.0, 0.0).y, GetOffsetFromEntityInWorldCoords(GetVehiclePedIsIn(GetPlayerPed(-1), false), -1.0 - (GetVehicleSteeringAngle(GetVehiclePedIsIn(GetPlayerPed(-1), false)) / GetVehicleHandlingFloat(GetVehiclePedIsIn(GetPlayerPed(-1), false), "CHandlingData", "fSteeringLock")), -6.0, 0.0).z, 255, 255, 255, 255)
end
else
lines = false
end
end
end)
end
end
if(args[1] == "mark") then
if IsPedInAnyVehicle(PlayerPedId(), false) then
--Is in a vehicle
else
minimap("Set as nearest vehicle")
local pos = GetEntityCoords(GetPlayerPed(-1),true)
local veh = GetClosestVehicle(pos.x,pos.y,pos.z,100000.00,0)
if IsEntityAVehicle(veh) then
tesla = veh
SetEntityAsMissionEntity(veh, true, true)
if(DoesBlipExist(tesla_blip)) then
RemoveBlip(tesla_blip)
end
tesla_blip = AddBlipForEntity(veh)
SetBlipSprite(tesla_blip, 79)
SetBlipColour(tesla_blip, 25)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("Car")
EndTextCommandSetBlipName(tesla_blip)
return
else
minimap("No vehicles in distance.")
return
end
end
if(IsPedInAnyVehicle(GetPlayerPed(-1)) and GetPedInVehicleSeat(GetVehiclePedIsIn(GetPlayerPed(-1), false), -1) == GetPlayerPed(-1) and (vehicles:find(GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsIn(GetPlayerPed(-1), false)))) or vehicles == "")) then
tesla = GetVehiclePedIsIn(GetPlayerPed(-1), false)
SetEntityAsMissionEntity(tesla, true, true)
minimap("Your vehicle was marked.")
if(DoesBlipExist(tesla_blip)) then
RemoveBlip(tesla_blip)
end
tesla_blip = AddBlipForEntity(tesla)
SetBlipSprite(tesla_blip, 79)
SetBlipColour(tesla_blip, 25)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("Car")
EndTextCommandSetBlipName(tesla_blip)
else
tesla = nil
minimap("Your vehicle was removed from your map.")
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) and (vehicles:find(GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsIn(GetPlayerPed(-1), false)))) or vehicles == "")) then
if(args[1] == "toggle" or args[1] == "on" or args[1] == nil) then
waypoint = Citizen.InvokeNative(0xFA7C7F0AADF25D09, GetFirstBlipInfoId(8), Citizen.ResultAsVector())
if(IsWaypointActive()) then
if(pilot) then
pilot = false
SetVehicleDoorOpen(tesla, 0, false)
minimap("Auto-Pilot disabled.")
ClearPedTasks(GetPlayerPed(-1))
else
pilot = true
minimap("Auto-Pilot activated.")
TaskVehicleDriveToCoord(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), 0), waypoint["x"], waypoint["y"], waypoint["z"], 30.0, 0.0, GetHashKey(GetVehiclePedIsIn(GetPlayerPed(-1), 0)), 525116, 0, true)
SetDriveTaskDrivingStyle(GetPlayerPed(-1),795452)
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))
SetVehicleDoorOpen(tesla, 0, false)
minimap("Auto-Pilot disabled.")
end
if(IsControlPressed(27, 63) or IsControlPressed(27, 64) or IsControlPressed(27, 71) or IsControlPressed(27, 72) or IsControlPressed(27, 76)or IsControlPressed(27, 131)) then
pilot = false
ClearPedTasks(GetPlayerPed(-1))
minimap("Auto-Pilot disabled.")
end
end
end)
end
else
minimap("No Waypoint was set.")
end
else
minimap("Unknown action.")
end
elseif(tesla) then
if(args[1] == "toggle" or args[1] == "on" or args[1] == nil) then
if(tesla_pilot) then
if(tesla_pilot_ped) then
RemovePedElegantly(tesla_pilot_ped)
end
tesla_pilot = false
tesla_pilot_ped = nil
SetVehicleEngineOn(tesla, false, false, false)
minimap("Auto-Pilot deactivated.")
else
RequestModel(225514697)
while not HasModelLoaded(225514697) do
Wait(5)
end
for i = 0, 6 do
SetVehicleDoorShut(tesla, i, false) -- will close all doors from 0-6
end
minimap("Auto-Pilot activated.")
tesla_pilot = true
tesla_pilot_ped = CreatePed(0, 225514697, GetEntityCoords(tesla)["x"], GetEntityCoords(tesla)["y"], GetEntityCoords(tesla)["z"], 0.0, false, true)
SetEntityAsMissionEntity(tesla_pilot_ped, true, true)
SetPedIntoVehicle(tesla_pilot_ped, tesla, -1)
SetEntityInvincible(tesla_pilot_ped, true)
SetEntityVisible(tesla_pilot_ped, false, 0)
player_coords = GetEntityCoords(GetPlayerPed(-1))
TaskVehicleDriveToCoord(tesla_pilot_ped, tesla, player_coords.x, player_coords.y, player_coords.z, 120.0, 0.0, GetHashKey(tesla),525116, 1.0, 1)
Citizen.CreateThread(function()
while tesla_pilot do
Wait(100)
if(GetDistanceBetweenCoords(GetEntityCoords(tesla)["x"], GetEntityCoords(tesla)["y"], GetEntityCoords(tesla)["z"], player_coords.x, player_coords.y, player_coords.z, 0) < 10.0) then
while GetEntitySpeed(tesla) - 1.0 > 0.0 do
SetVehicleForwardSpeed(tesla, GetEntitySpeed(tesla) - 1.0)
Wait(100)
end
tesla_pilot = false
RemovePedElegantly(tesla_pilot_ped)
tesla_pilot_ped = nil
SetVehicleDoorOpen(tesla, 0, false, true)
SetVehicleEngineOn(tesla, false, false, false)
minimap("Auto-Pilot arrived.")
end
end
end)
end
end
else
minimap("Unknown vehicle.")
end
end
end, false)
function minimap(text)
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
DrawNotification(0,1)
end