Script Dokumentation LS 2015 - SetCruiseControlStateEvent (Patch 1.3)
scripts/vehicles/specializations/SetCruiseControlStateEvent.lua
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
1 | -- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved. |
2 | |
3 | SetCruiseControlStateEvent = {}; |
4 | SetCruiseControlStateEvent_mt = Class(SetCruiseControlStateEvent, Event); |
5 | |
6 | InitStaticEventClass(SetCruiseControlStateEvent, "SetCruiseControlStateEvent", EventIds.EVENT_CRUISECONTROL_SET_STATE); |
7 | |
8 | function SetCruiseControlStateEvent:emptyNew() |
9 | local self = Event:new(SetCruiseControlStateEvent_mt); |
10 | return self; |
11 | end; |
12 | |
13 | function SetCruiseControlStateEvent:new(vehicle, state) |
14 | local self = SetCruiseControlStateEvent:emptyNew() |
15 | self.state = state; |
16 | self.vehicle = vehicle; |
17 | return self; |
18 | end; |
19 | |
20 | function SetCruiseControlStateEvent:readStream(streamId, connection) |
21 | local id = streamReadInt32(streamId); |
22 | self.state = streamReadUIntN(streamId, 2); |
23 | self.vehicle = networkGetObject(id); |
24 | self:run(connection); |
25 | end; |
26 | |
27 | function SetCruiseControlStateEvent:writeStream(streamId, connection) |
28 | streamWriteInt32(streamId, networkGetObjectId(self.vehicle)); |
29 | streamWriteUIntN(streamId, self.state, 2); |
30 | end; |
31 | |
32 | function SetCruiseControlStateEvent:run(connection) |
33 | self.vehicle:setCruiseControlState(self.state, true); |
34 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de