LUADOC - Farming Simulator 17

Printable Version

Script v1.4.4.0

Engine v7.0.0.2

Foundation Reference

OverloadingToggleUnloadEvent

Description
Event for toggle overloading
Functions

emptyNew

Description
Create instance of Event class
Definition
emptyNew()
Return Values
tableselfinstance of class event
Code
15function OverloadingToggleUnloadEvent:emptyNew()
16 local self = Event:new(OverloadingToggleUnloadEvent_mt);
17 return self;
18end;

new

Description
Create new instance of event
Definition
new(table object, boolean isActive)
Arguments
tableobjectobject
booleanisActiveis active
Code
24function OverloadingToggleUnloadEvent:new(vehicle, isActive)
25 local self = OverloadingToggleUnloadEvent:emptyNew()
26 self.vehicle = vehicle;
27 self.isActive = isActive;
28 return self;
29end;

readStream

Description
Called on client side on join
Definition
readStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
35function OverloadingToggleUnloadEvent:readStream(streamId, connection)
36 self.vehicle = readNetworkNodeObject(streamId);
37 self.isActive = streamReadBool(streamId);
38 self:run(connection);
39end;

writeStream

Description
Called on server side on join
Definition
writeStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
45function OverloadingToggleUnloadEvent:writeStream(streamId, connection)
46 writeNetworkNodeObject(streamId, self.vehicle);
47 streamWriteBool(streamId, self.isActive);
48end;

run

Description
Run action on receiving side
Definition
run(integer connection)
Arguments
integerconnectionconnection
Code
53function OverloadingToggleUnloadEvent:run(connection)
54 self.vehicle:setOverloadingActive(self.isActive, true);
55 if not connection:getIsServer() then
56 g_server:broadcastEvent(OverloadingToggleUnloadEvent:new(self.vehicle, self.isActive), nil, connection, self.vehicle);
57 end;
58end;

sendEvent

Description
Broadcast event from server to all clients, if called on client call function on server and broadcast it to all clients
Definition
sendEvent(table vehicle, boolean isActive, boolean noEventSend)
Arguments
tablevehiclevehicle
booleanisActiveis active
booleannoEventSendno event send
Code
65function OverloadingToggleUnloadEvent.sendEvent(vehicle, isActive, noEventSend)
66 if noEventSend == nil or noEventSend == false then
67 if g_server ~= nil then
68 g_server:broadcastEvent(OverloadingToggleUnloadEvent:new(vehicle, isActive), nil, nil, vehicle);
69 else
70 g_client:getServerConnection():sendEvent(OverloadingToggleUnloadEvent:new(vehicle, isActive));
71 end;
72 end;
73end;