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 | HonkEvent = {}; |
4 | HonkEvent_mt = Class(HonkEvent, Event); |
5 | |
6 | InitStaticEventClass(HonkEvent, "HonkEvent", EventIds.EVENT_HONK); |
7 | |
8 | function HonkEvent:emptyNew() |
9 | local self = Event:new(HonkEvent_mt); |
10 | return self; |
11 | end; |
12 | |
13 | function HonkEvent:new(object, isPlaying) |
14 | local self = HonkEvent:emptyNew() |
15 | self.object = object; |
16 | self.isPlaying = isPlaying; |
17 | return self; |
18 | end; |
19 | |
20 | function HonkEvent:readStream(streamId, connection) |
21 | local id = streamReadInt32(streamId); |
22 | self.isPlaying = streamReadBool(streamId); |
23 | self.object = networkGetObject(id); |
24 | self:run(connection); |
25 | end; |
26 | |
27 | function HonkEvent:writeStream(streamId, connection) |
28 | streamWriteInt32(streamId, networkGetObjectId(self.object)); |
29 | streamWriteBool(streamId, self.isPlaying); |
30 | end; |
31 | |
32 | function 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; |
37 | end; |
38 | |
39 | function 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; |
49 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de