Script Dokumentation LS 2015 - SetMotorTurnedOnEvent (Patch 1.3)
scripts/vehicles/specializations/SetMotorTurnedOnEvent.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 | SetMotorTurnedOnEvent = {}; |
4 | SetMotorTurnedOnEvent_mt = Class(SetMotorTurnedOnEvent, Event); |
5 | |
6 | InitStaticEventClass(SetMotorTurnedOnEvent, "SetMotorTurnedOnEvent", EventIds.EVENT_SET_MOTOR_TURNED_ON); |
7 | |
8 | function SetMotorTurnedOnEvent:emptyNew() |
9 | local self = Event:new(SetMotorTurnedOnEvent_mt); |
10 | return self; |
11 | end; |
12 | |
13 | function SetMotorTurnedOnEvent:new(object, turnedOn) |
14 | local self = SetMotorTurnedOnEvent:emptyNew() |
15 | self.object = object; |
16 | self.turnedOn = turnedOn; |
17 | return self; |
18 | end; |
19 | |
20 | function SetMotorTurnedOnEvent:readStream(streamId, connection) |
21 | local id = streamReadInt32(streamId); |
22 | self.turnedOn = streamReadBool(streamId); |
23 | self.object = networkGetObject(id); |
24 | self:run(connection); |
25 | end; |
26 | |
27 | function SetMotorTurnedOnEvent:writeStream(streamId, connection) |
28 | streamWriteInt32(streamId, networkGetObjectId(self.object)); |
29 | streamWriteBool(streamId, self.turnedOn); |
30 | end; |
31 | |
32 | function SetMotorTurnedOnEvent:run(connection) |
33 | if self.turnedOn then |
34 | self.object:startMotor(true); |
35 | else |
36 | self.object:stopMotor(true); |
37 | end; |
38 | if not connection:getIsServer() then |
39 | g_server:broadcastEvent(SetMotorTurnedOnEvent:new(self.object, self.turnedOn), nil, connection, self.object); |
40 | end; |
41 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de