Sprache Deutsch Language English

Script Dokumentation LS 2015 - ChainsawStateEvent (Patch 1.3)

Script Dokumentation Übersicht

scripts/handTools/ChainsawStateEvent.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
3ChainsawStateEvent = {};
4ChainsawStateEvent_mt = Class(ChainsawStateEvent, Event);
5
6InitStaticEventClass(ChainsawStateEvent, "ChainsawStateEvent", EventIds.EVENT_CHAINSAW_STATE);
7
8function ChainsawStateEvent:emptyNew()
9 local self = Event:new(ChainsawStateEvent_mt);
10 return self;
11end;
12
13function ChainsawStateEvent:new(player, isCutting, isHorizontalCut)
14 local self = ChainsawStateEvent:emptyNew()
15 self.player = player;
16 self.isCutting = isCutting;
17 self.isHorizontalCut = isHorizontalCut;
18 return self;
19end;
20
21function ChainsawStateEvent:readStream(streamId, connection)
22 self.player = networkGetObject(streamReadInt32(streamId));
23 self.isCutting = streamReadBool(streamId);
24 self.isHorizontalCut = streamReadBool(streamId);
25 self:run(connection);
26end;
27
28function ChainsawStateEvent:writeStream(streamId, connection)
29 streamWriteInt32(streamId, networkGetObjectId(self.player));
30 streamWriteBool(streamId, self.isCutting);
31 streamWriteBool(streamId, self.isHorizontalCut);
32end;
33
34function ChainsawStateEvent:run(connection)
35 if not connection:getIsServer() then
36 g_server:broadcastEvent(self, false, connection, self.player);
37 end;
38
39 local currentTool = self.player.currentTool;
40 if currentTool ~= nil and currentTool.setCutting ~= nil then
41 currentTool:setCutting(self.isCutting, self.isHorizontalCut, true);
42 end;
43end;
44
45function ChainsawStateEvent.sendEvent(player, isCutting, isHorizontalCut, noEventSend)
46 local currentTool = player.currentTool;
47 if currentTool ~= nil and currentTool.setCutting ~= nil and currentTool.isCutting ~= isCutting then
48 if noEventSend == nil or noEventSend == false then
49 if g_server ~= nil then
50 g_server:broadcastEvent(ChainsawStateEvent:new(player, isCutting, isHorizontalCut), nil, nil, player);
51 else
52 g_client:getServerConnection():sendEvent(ChainsawStateEvent:new(player, isCutting, isHorizontalCut));
53 end;
54 end;
55 end;
56end;
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