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