-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.lua
More file actions
223 lines (184 loc) · 6.24 KB
/
client.lua
File metadata and controls
223 lines (184 loc) · 6.24 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
local called = false;
local arrivedCity = false;
local realtimeDistanceToCallMarker = 15.0
local availableBucketsRange = { 0, 50 }
-- As we mes with routing buckets, we need to default the player to bucket 0 to overwrite the old bucket
TriggerServerEvent("airbus:exit")
-- Make sure the player blip is visible
SetBlipDisplay(GetMainPlayerBlipId(), 8);
-- Get player distance to marker
CreateThread(function(threadId)
while not arrivedCity do
Wait(500)
local playerCoords = GetEntityCoords(PlayerPedId())
realtimeDistanceToCallMarker = #(playerCoords - Config.CallMarker)
end
end)
-- As long as airbus is not called and distance < 15.0, draw the marker and display the help text
CreateThread(function(threadId)
while (not called) do
Wait(0)
if (realtimeDistanceToCallMarker < Config.MarkerDrawDistance and not called) then
DrawMarker(2, Config.CallMarker.x, Config.CallMarker.y, Config.CallMarker.z + 2, 0.0, 0.0, 0.0, 0.0, 180.0, 0.0, 1.0, 1.0, 1.0, 255, 128, 0, 50, false, true, 2, false, nil, nil, false)
end
if (realtimeDistanceToCallMarker < Config.MarkerInteraction and not called) then
BeginTextCommandDisplayHelp("STRING")
AddTextComponentString("Press ~INPUT_CONTEXT~ to call AIR-BUS.")
EndTextCommandDisplayHelp(0, false, true, -1)
if (IsControlJustPressed(0, 38)) then
called = true;
TriggerServerEvent("airbus:enter")
end
end
end
end)
-- Function to call the airbus
function CallAirbus()
RequestModel(Config.Driver)
while not HasModelLoaded(Config.Driver) do
Wait(100)
end
if (HasModelLoaded(Config.Driver)) then
local driver = CreatePed(0, Config.Driver, -1067.831, -2559.146, 21.0, 237.912, true, true)
if DoesEntityExist(driver) then
SetPedComponentVariation(driver, 2, 4, 4, 0) -- Hair
SetPedComponentVariation(driver, 7, 38, 0, 0); -- Accessory
SetPedComponentVariation(driver, 11, 242, 1, 0); -- Torso
SetPedComponentVariation(driver, 8, 15, 0, 0); -- T-Shirt
SetPedComponentVariation(driver, 4, 35, 0, 0); -- Pants
SetPedComponentVariation(driver, 6, 21, 0, 0); -- Shoes
RequestModel(Config.Vehicle)
while not HasModelLoaded(Config.Vehicle) do
Wait(100)
end
if (HasModelLoaded(Config.Vehicle)) then
local airbus = CreateVehicle(Config.Vehicle, -1062.101, -2555.909, 20.07566, 150.1505, true, false)
if DoesEntityExist(airbus) then
local airbusBlip = AddBlipForEntity(airbus)
SetBlipSprite(airbusBlip, 513)
SetBlipColour(airbusBlip, 0)
SetBlipScale(airbusBlip, 0.8)
SetBlipFlashes(airbusBlip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("AIR-BUS")
EndTextCommandSetBlipName(airbusBlip)
TaskWarpPedIntoVehicle(driver, airbus, -1)
-- Set the vehicle properties
SetVehicleOnGroundProperly(airbus)
SetVehicleNumberPlateText(airbus, "AIRBUS")
SetVehicleEngineOn(airbus, true, true, false)
SetVehicleLivery(airbus, 1)
TaskVehicleDriveToCoord(
driver,
airbus,
-1050.137,
-2720.53,
20.08276,
10.0,
nil,
Config.Vehicle,
786599,
5.0, nil
)
BeginTextCommandDisplayHelp("STRING")
AddTextComponentString("AIR-BUS ~BLIP_BUS~ is on its way to the bus station ~BLIP_LEVEL~")
EndTextCommandDisplayHelp(0, false, true, 8000)
local stationBlip = AddBlipForCoord(-1045.806, -2722.468, 20.10379)
SetBlipColour(stationBlip, 0)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("AIR-BUS Station")
EndTextCommandSetBlipName(stationBlip)
Wait(4000)
SetBlipFlashes(airbusBlip, false)
Wait(10000)
-- Wait for bus to arrive at the station
while (#(GetEntityCoords(airbus) - vector3(-1050.137, -2720.53, 20.08276)) > 15.0) do
Wait(1000)
end
-- Bus has arrived at the station
RemoveBlip(stationBlip)
SetEntityCoords(airbus, -1050.137, -2720.53, 20.08276, false, false, false, true)
SetEntityHeading(airbus, 238.8681)
FlashMinimapDisplay()
BeginTextCommandDisplayHelp("STRING")
AddTextComponentString("AIR-BUS ~BLIP_BUS~ has arrived at the bus station ~BLIP_LEVEL~")
EndTextCommandDisplayHelp(0, false, true, 4000)
-- Wait for player to enter the bus
while (#(GetEntityCoords(PlayerPedId()) - vector3(-1041.774, -2726.878, 20.01925)) > 10.0) do
Wait(0)
end
while (not IsControlJustPressed(0, 23)) do
Wait(0)
end
TaskEnterVehicle(
PlayerPedId(),
airbus,
-1,
0,
1.0,
1,
0
)
Wait(500)
SetFollowPedCamViewMode(4)
Wait(6000)
SetFollowVehicleCamViewMode(4)
BeginTextCommandDisplayHelp("STRING")
AddTextComponentString("AIR-BUS ~BLIP_BUS~ is departuring.")
EndTextCommandDisplayHelp(0, false, true, 4000)
SetBlipDisplay(GetMainPlayerBlipId(), 0);
SetNewWaypoint(298.8799, -1202.714);
TaskVehicleDriveToCoord(
driver,
airbus,
259.2122,
-1179.586,
29.44427,
20.0,
nil,
Config.Vehicle,
786599,
5.0, nil
)
-- Wait for bus to arrive at the destination
while (#(GetEntityCoords(airbus) - vector3(259.2122, -1179.586, 29.44427)) > 10.0) do
-- If player gets out early
if (not IsPedInVehicle(PlayerPedId(), airbus, false)) then
SetBlipDisplay(GetMainPlayerBlipId(), 8);
Wait(2000)
DeleteEntity(driver)
DeleteEntity(airbus)
arrivedCity = true;
TriggerServerEvent("airbus:exit")
end
Wait(1000)
end
BeginTextCommandDisplayHelp("STRING")
AddTextComponentString("AIR-BUS ~BLIP_BUS~ has arrived at the destination.")
EndTextCommandDisplayHelp(0, false, true, 4000)
Wait(1000)
TaskLeaveVehicle(PlayerPedId(), airbus, 0)
-- Wait for player to exit the bus
while (IsPedInVehicle(PlayerPedId(), airbus, false)) do
Wait(1000)
end
SetBlipDisplay(GetMainPlayerBlipId(), 8);
Wait(2000)
DeleteEntity(driver)
DeleteEntity(airbus)
arrivedCity = true;
TriggerServerEvent("airbus:exit")
else
print("[ERROR] Entity airbus does not exist.")
end
end
else
print("[ERROR] Entity driver does not exist.")
end
end
end
RegisterNetEvent("airbus:enterDone")
AddEventHandler("airbus:enterDone", function()
Wait(1000)
CallAirbus()
end)