LUADOC - Farming Simulator 19

PlayerTeleportEvent

Parent
Event
Functions

emptyNew

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

new

Description
Create an instance
Definition
new(float x, float y, float z, bool isAbsolute, bool isRootNode, float z)
Arguments
floatxworld x position
floatyworld y position
floatzworld z position
boolisAbsoluteif not true, y is a delta from the terrain
boolisRootNodeif true, y is the root node location, otherwise y is the feet location
floatzworld z position
Return Values
tableinstanceInstance of object
Code
25function PlayerTeleportEvent:new(x, y, z, isAbsolute, isRootNode)
26 local self = PlayerTeleportEvent:emptyNew()
27 self.x = x
28 self.y = y
29 self.z = z
30 self.isAbsolute = isAbsolute
31 self.isRootNode = isRootNode
32 return self
33end

newExitVehicle

Description
Create an instance when player exits vehicle
Definition
newExitVehicle(table exitVehicle)
Arguments
tableexitVehicleinstance of the vehicle that the player exits
Return Values
tableinstanceInstance of object
Code
39function PlayerTeleportEvent:newExitVehicle(exitVehicle)
40 local self = PlayerTeleportEvent:emptyNew()
41 self.exitVehicle = exitVehicle
42 return self
43end

readStream

Description
Reads network stream
Definition
readStream(integer streamId, table connection)
Arguments
integerstreamIdnetwork stream identification
tableconnectionconnection information
Code
49function PlayerTeleportEvent:readStream(streamId, connection)
50 if streamReadBool(streamId) then
51 self.exitVehicle = NetworkUtil.readNodeObject(streamId)
52 else
53 self.x = streamReadFloat32(streamId)
54 self.y = streamReadFloat32(streamId)
55 self.z = streamReadFloat32(streamId)
56 self.isAbsolute = streamReadBool(streamId)
57 self.isRootNode = streamReadBool(streamId)
58 end
59 self:run(connection)
60end

run

Description
Run event
Definition
run(table connection)
Arguments
tableconnectionconnection information
Code
81function PlayerTeleportEvent:run(connection)
82 if not connection:getIsServer() then
83 local player = g_currentMission.connectionsToPlayer[connection]
84 if player ~= nil then
85 if self.exitVehicle ~= nil then
86 player:moveToExitPoint(self.exitVehicle)
87 elseif self.x ~= nil then
88 player:moveTo(self.x,self.y,self.z,self.isAbsolute,self.isRootNode)
89 end
90 end
91 end
92end

writeStream

Description
Writes network stream
Definition
writeStream(integer streamId, table connection)
Arguments
integerstreamIdnetwork stream identification
tableconnectionconnection information
Code
66function PlayerTeleportEvent:writeStream(streamId, connection)
67 if streamWriteBool(streamId, self.exitVehicle ~= nil) then
68 NetworkUtil.writeNodeObject(streamId, self.exitVehicle)
69 else
70 streamWriteFloat32(streamId, self.x)
71 streamWriteFloat32(streamId, self.y)
72 streamWriteFloat32(streamId, self.z)
73 streamWriteBool(streamId, self.isAbsolute)
74 streamWriteBool(streamId, self.isRootNode)
75 end
76end