Sprache Deutsch Language English

Script Dokumentation LS 2015 - VehicleAttachEvent (Patch 1.3)

Script Dokumentation Übersicht

scripts/vehicles/VehicleAttachEvent.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
3VehicleAttachEvent = {};
4VehicleAttachEvent_mt = Class(VehicleAttachEvent, Event);
5
6InitStaticEventClass(VehicleAttachEvent, "VehicleAttachEvent", EventIds.EVENT_VEHICLE_ATTACH);
7
8function VehicleAttachEvent:emptyNew()
9 local self = Event:new(VehicleAttachEvent_mt);
10 return self;
11end;
12
13function VehicleAttachEvent:new(vehicle, implement, inputJointIndex, jointIndex, startLowered)
14 local self = VehicleAttachEvent:emptyNew()
15 self.jointIndex = jointIndex;
16 self.inputJointIndex = inputJointIndex;
17 self.vehicle = vehicle;
18 self.implement = implement;
19 self.startLowered = startLowered;
20 assert(self.jointIndex >= 0 and self.jointIndex < 127)
21 return self;
22end;
23
24function VehicleAttachEvent:readStream(streamId, connection)
25 local id = streamReadInt32(streamId);
26 local implementId = streamReadInt32(streamId);
27 self.jointIndex = streamReadUIntN(streamId, 7);
28 self.inputJointIndex = streamReadUIntN(streamId, 7);
29 self.startLowered = streamReadBool(streamId);
30 self.vehicle = networkGetObject(id);
31 self.implement = networkGetObject(implementId);
32 self:run(connection);
33end;
34
35function VehicleAttachEvent:writeStream(streamId, connection)
36 streamWriteInt32(streamId, networkGetObjectId(self.vehicle));
37 streamWriteInt32(streamId, networkGetObjectId(self.implement));
38 streamWriteUIntN(streamId, self.jointIndex, 7);
39 streamWriteUIntN(streamId, self.inputJointIndex, 7);
40 streamWriteBool(streamId, self.startLowered);
41end;
42
43function VehicleAttachEvent:run(connection)
44 self.vehicle:attachImplement(self.implement, self.inputJointIndex, self.jointIndex, true, nil, self.startLowered);
45 if not connection:getIsServer() then
46 g_server:broadcastEvent(self, nil, connection, self.object);
47 end;
48end;
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