Sprache Deutsch Language English

Script Dokumentation LS 2015 - PickupSetStateEvent (Patch 1.3)

Script Dokumentation Übersicht

scripts/vehicles/specializations/PickupSetStateEvent.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
3PickupSetStateEvent = {};
4PickupSetStateEvent_mt = Class(PickupSetStateEvent, Event);
5
6InitStaticEventClass(PickupSetStateEvent, "PickupSetStateEvent", EventIds.EVENT_SET_PICKUP_STATE);
7
8function PickupSetStateEvent:emptyNew()
9 local self = Event:new(PickupSetStateEvent_mt);
10 return self;
11end;
12
13function PickupSetStateEvent:new(object, isPickupLowered)
14 local self = PickupSetStateEvent:emptyNew()
15 self.object = object;
16 self.isPickupLowered = isPickupLowered;
17 return self;
18end;
19
20function PickupSetStateEvent:readStream(streamId, connection)
21 local id = streamReadInt32(streamId);
22 self.isPickupLowered = streamReadBool(streamId);
23 self.object = networkGetObject(id);
24 self:run(connection);
25end;
26
27function PickupSetStateEvent:writeStream(streamId, connection)
28 streamWriteInt32(streamId, networkGetObjectId(self.object));
29 streamWriteBool(streamId, self.isPickupLowered);
30end;
31
32function PickupSetStateEvent: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:setPickupState(self.isPickupLowered, true);
38 end;
39end;
40
41function PickupSetStateEvent.sendEvent(vehicle, isPickupLowered, noEventSend)
42 if isPickupLowered ~= vehicle.isPickupLowered then
43 if noEventSend == nil or noEventSend == false then
44 if g_server ~= nil then
45 g_server:broadcastEvent(PickupSetStateEvent:new(vehicle, isPickupLowered), nil, nil, vehicle);
46 else
47 g_client:getServerConnection():sendEvent(PickupSetStateEvent:new(vehicle, isPickupLowered));
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