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 | CombineStrawEnableEvent = {}; |
4 | CombineStrawEnableEvent_mt = Class(CombineStrawEnableEvent, Event); |
5 | |
6 | InitStaticEventClass(CombineStrawEnableEvent, "CombineStrawEnableEvent", EventIds.EVENT_COMBINE_ENABLE_STRAW); |
7 | |
8 | function CombineStrawEnableEvent:emptyNew() |
9 | local self = Event:new(CombineStrawEnableEvent_mt); |
10 | return self; |
11 | end; |
12 | |
13 | function CombineStrawEnableEvent:new(vehicle, isStrawEnabled) |
14 | local self = CombineStrawEnableEvent:emptyNew() |
15 | self.vehicle = vehicle; |
16 | self.isStrawEnabled = isStrawEnabled; |
17 | return self; |
18 | end; |
19 | |
20 | function CombineStrawEnableEvent:readStream(streamId, connection) |
21 | local id = streamReadInt32(streamId); |
22 | self.isStrawEnabled = streamReadBool(streamId); |
23 | self.vehicle = networkGetObject(id); |
24 | self:run(connection); |
25 | end; |
26 | |
27 | function CombineStrawEnableEvent:writeStream(streamId, connection) |
28 | streamWriteInt32(streamId, networkGetObjectId(self.vehicle)); |
29 | streamWriteBool(streamId, self.isStrawEnabled); |
30 | end; |
31 | |
32 | function CombineStrawEnableEvent:run(connection) |
33 | self.vehicle:setIsStrawEnabled(self.isStrawEnabled, true); |
34 | if not connection:getIsServer() then |
35 | g_server:broadcastEvent(CombineStrawEnableEvent:new(self.vehicle, self.isStrawEnabled), nil, connection, self.vehicle); |
36 | end; |
37 | end; |
38 | |
39 | function CombineStrawEnableEvent.sendEvent(vehicle, isStrawEnabled, noEventSend) |
40 | if noEventSend == nil or noEventSend == false then |
41 | if g_server ~= nil then |
42 | g_server:broadcastEvent(CombineStrawEnableEvent:new(vehicle, isStrawEnabled), nil, nil, vehicle); |
43 | else |
44 | g_client:getServerConnection():sendEvent(CombineStrawEnableEvent:new(vehicle, isStrawEnabled)); |
45 | end; |
46 | end; |
47 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de