LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

PlayerSetStyleEvent

Parent
Event
Functions

emptyNew

Description
Create an empty instance
Definition
emptyNew()
Return Values
tableinstanceInstance of object
Code
11function PlayerSetStyleEvent.emptyNew()
12 local self = Event.new(PlayerSetStyleEvent_mt)
13 return self
14end

new

Description
Create an instance
Definition
new()
Code
18function PlayerSetStyleEvent.new(player, style)
19 local self = PlayerSetStyleEvent.emptyNew()
20
21 self.player = player
22 self.style = style
23
24 return self
25end

readStream

Description
Reads network stream
Definition
readStream(integer streamId, table connection)
Arguments
integerstreamIdnetwork stream identification
tableconnectionconnection information
Code
40function PlayerSetStyleEvent:readStream(streamId, connection)
41 self.player = NetworkUtil.readNodeObject(streamId)
42
43 self.style = PlayerStyle.new()
44 self.style:readStream(streamId, connection)
45
46 self:run(connection)
47end

run

Description
Run event
Definition
run(table connection)
Arguments
tableconnectionconnection information
Code
52function PlayerSetStyleEvent:run(connection)
53 if not connection:getIsServer() then --server side
54 self.player:setStyleAsync(self.style, nil, false)
55 else -- client side
56 self.player:setStyleAsync(self.style, nil, true) -- do not send to server again
57 end
58end

sendEvent

Description
Create an instance
Definition
sendEvent(table player, integer farmId, bool noEventSend)
Arguments
tableplayerplayer instance
integerfarmIdfarm identification
boolnoEventSendif false will send the event
Code
65function PlayerSetStyleEvent.sendEvent(player, style, noEventSend)
66 if noEventSend == nil or noEventSend == false then
67 if g_server ~= nil then
68 g_server:broadcastEvent(PlayerSetStyleEvent.new(player, style), nil, nil, player)
69 else
70 g_client:getServerConnection():sendEvent(PlayerSetStyleEvent.new(player, style))
71 end
72 end
73end

writeStream

Description
Writes network stream
Definition
writeStream(integer streamId, table connection)
Arguments
integerstreamIdnetwork stream identification
tableconnectionconnection information
Code
31function PlayerSetStyleEvent:writeStream(streamId, connection)
32 NetworkUtil.writeNodeObject(streamId, self.player)
33 self.style:writeStream(streamId, connection)
34end