Sprache Deutsch Language English

Script Dokumentation LS 2015 - StrawBlowerDoorOpenEvent (Patch 1.3)

Script Dokumentation Übersicht

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