forked from Dukefarming/FS25-lua-scripting
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVehicleDetachEvent.lua
More file actions
64 lines (42 loc) · 1.49 KB
/
VehicleDetachEvent.lua
File metadata and controls
64 lines (42 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
---Event for detaching
local VehicleDetachEvent_mt = Class(VehicleDetachEvent, Event)
---Create instance of Event class
-- @return table self instance of class event
function VehicleDetachEvent.emptyNew()
local self = Event.new(VehicleDetachEvent_mt)
return self
end
---Create new instance of event
-- @param table vehicle vehicle
-- @param table implement implement
-- @return table instance instance of event
function VehicleDetachEvent.new(vehicle, implement)
local self = VehicleDetachEvent.emptyNew()
self.implement = implement
self.vehicle = vehicle
return self
end
---Called on client side on join
-- @param integer streamId streamId
-- @param integer connection connection
function VehicleDetachEvent:readStream(streamId, connection)
self.vehicle = NetworkUtil.readNodeObject(streamId)
self.implement = NetworkUtil.readNodeObject(streamId)
if self.vehicle ~= nil and self.vehicle:getIsSynchronized() then
if connection:getIsServer() then
self.vehicle:detachImplementByObject(self.implement, true)
else
self.vehicle:detachImplementByObject(self.implement)
end
end
end
---Called on server side on join
-- @param integer streamId streamId
-- @param integer connection connection
function VehicleDetachEvent:writeStream(streamId, connection)
NetworkUtil.writeNodeObject(streamId, self.vehicle)
NetworkUtil.writeNodeObject(streamId, self.implement)
end
---
function VehicleDetachEvent:run(connection)
end