-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.lua
More file actions
49 lines (43 loc) · 1.49 KB
/
server.lua
File metadata and controls
49 lines (43 loc) · 1.49 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
local carrying = {}
--carrying[source] = targetSource, source is carrying targetSource
local carried = {}
--carried[targetSource] = source, targetSource is being carried by source
RegisterServerEvent("CarryPeople:sync")
AddEventHandler("CarryPeople:sync", function(targetSrc)
local source = source
local sourcePed = GetPlayerPed(source)
local sourceCoords = GetEntityCoords(sourcePed)
local targetPed = GetPlayerPed(targetSrc)
local targetCoords = GetEntityCoords(targetPed)
if #(sourceCoords - targetCoords) <= 3.0 then
TriggerClientEvent("CarryPeople:syncTarget", targetSrc, source)
carrying[source] = targetSrc
carried[targetSrc] = source
end
end)
RegisterServerEvent("CarryPeople:stop")
AddEventHandler("CarryPeople:stop", function(targetSrc)
local source = source
if carrying[source] then
TriggerClientEvent("CarryPeople:cl_stop", targetSrc)
carrying[source] = nil
carried[targetSrc] = nil
elseif carried[source] then
TriggerClientEvent("CarryPeople:cl_stop", carried[source])
carrying[carried[source]] = nil
carried[source] = nil
end
end)
AddEventHandler('playerDropped', function(reason)
local source = source
if carrying[source] then
TriggerClientEvent("CarryPeople:cl_stop", carrying[source])
carried[carrying[source]] = nil
carrying[source] = nil
end
if carried[source] then
TriggerClientEvent("CarryPeople:cl_stop", carried[source])
carrying[carried[source]] = nil
carried[source] = nil
end
end)