Script Dokumentation LS 2015 - AITractorSetStartedEvent (Patch 1.3)
scripts/vehicles/specializations/AITractorSetStartedEvent.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 | |
3 | AITractorSetStartedEvent = {}; |
4 | AITractorSetStartedEvent_mt = Class(AITractorSetStartedEvent, Event); |
5 | |
6 | InitStaticEventClass(AITractorSetStartedEvent, "AITractorSetStartedEvent", EventIds.EVENT_AITRACTOR_SET_STARTED); |
7 | |
8 | function AITractorSetStartedEvent:emptyNew() |
9 | local self = Event:new(AITractorSetStartedEvent_mt); |
10 | return self; |
11 | end; |
12 | |
13 | function AITractorSetStartedEvent:new(object, isStarted) |
14 | local self = AITractorSetStartedEvent:emptyNew() |
15 | self.object = object; |
16 | self.isStarted = isStarted; |
17 | return self; |
18 | end; |
19 | |
20 | function AITractorSetStartedEvent:readStream(streamId, connection) |
21 | local id = streamReadInt32(streamId); |
22 | self.isStarted = streamReadBool(streamId); |
23 | self.object = networkGetObject(id); |
24 | self:run(connection); |
25 | end; |
26 | |
27 | function AITractorSetStartedEvent:writeStream(streamId, connection) |
28 | streamWriteInt32(streamId, networkGetObjectId(self.object)); |
29 | streamWriteBool(streamId, self.isStarted); |
30 | end; |
31 | |
32 | function AITractorSetStartedEvent:run(connection) |
33 | if self.isStarted then |
34 | self.object:startAITractor(true); |
35 | else |
36 | self.object:stopAITractor(true); |
37 | end; |
38 | if not connection:getIsServer() then |
39 | for k, v in pairs(g_server.clientConnections) do |
40 | if v ~= connection and not v:getIsLocal() then |
41 | v:sendEvent(AITractorSetStartedEvent:new(self.object, self.isStarted)); |
42 | end; |
43 | end; |
44 | end; |
45 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de