-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.lua
More file actions
44 lines (37 loc) · 1.1 KB
/
server.lua
File metadata and controls
44 lines (37 loc) · 1.1 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
local buckets = {}
for i = 1,50 do
table.insert(buckets, 1000 + i)
end
local playerBuckets = {}
RegisterNetEvent("airbus:enter")
AddEventHandler("airbus:enter", function()
local source = source
if playerBuckets[source] then
return
end
local playerPed = GetPlayerPed(source)
local playerCoords = GetEntityCoords(playerPed)
local distance = #(playerCoords - Config.CallMarker)
if distance <= Config.CallMaxDistance then
if #buckets > 0 then
local bucket = table.remove(buckets, 1)
playerBuckets[source] = bucket
SetPlayerRoutingBucket(source, bucket)
TriggerClientEvent("airbus:enterDone", source)
else
print("All buses are busy")
end
else
print("Player too far away from the callbus marker")
end
end)
RegisterNetEvent("airbus:exit")
AddEventHandler("airbus:exit", function()
local source = source
local bucket = playerBuckets[source]
if bucket then
table.insert(buckets, bucket)
playerBuckets[source] = nil
end
SetPlayerRoutingBucket(source, 0)
end)