Sprache Deutsch Language English

Script Dokumentation LS 2015 - HonkEvent (Patch 1.3)

Script Dokumentation Übersicht

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