Skip to main content
Skip to main content

VehicleAttachRequestEvent

VehicleAttachRequestEvent

Description

Event for request attaching

Parent

Event

Functions

emptyNew

Description

Create instance of Event class

Definition

emptyNew()

Return Values

anyselfinstance of class event

Code

function VehicleAttachRequestEvent.emptyNew()
return Event.new( VehicleAttachRequestEvent _mt)
end

new

Description

Create new instance of event

Definition

new(table info)

Arguments

tableinfoattach info [attacherVehicle, attachable, attacherVehicleJointDescIndex, attachableJointDescIndex]

Return Values

tableinstanceinstance of event

Code

function VehicleAttachRequestEvent.new(info)
local self = VehicleAttachRequestEvent.emptyNew()
self.attacherVehicle = info.attacherVehicle
self.attachable = info.attachable
self.attacherVehicleJointDescIndex = info.attacherVehicleJointDescIndex
self.attachableJointDescIndex = info.attachableJointDescIndex
return self
end

readStream

Description

Called on client side on join

Definition

readStream(integer streamId, Connection connection)

Arguments

integerstreamIdstreamId
Connectionconnectionconnection

Code

function VehicleAttachRequestEvent:readStream(streamId, connection)
self.attacherVehicle = NetworkUtil.readNodeObject(streamId)
self.attachable = NetworkUtil.readNodeObject(streamId)
self.attacherVehicleJointDescIndex = streamReadUIntN(streamId, 7 )
self.attachableJointDescIndex = streamReadUIntN(streamId, 7 )
self:run(connection)
end

run

Description

Run action on receiving side

Definition

run(Connection connection)

Arguments

Connectionconnectionconnection

Code

function VehicleAttachRequestEvent:run(connection)
if not connection:getIsServer() then
if self.attacherVehicle ~ = nil and self.attacherVehicle:getIsSynchronized() then
self.attacherVehicle:attachImplementFromInfo( self )
end
end
end

writeStream

Description

Called on server side on join

Definition

writeStream(integer streamId, Connection connection)

Arguments

integerstreamIdstreamId
Connectionconnectionconnection

Code

function VehicleAttachRequestEvent:writeStream(streamId, connection)
NetworkUtil.writeNodeObject(streamId, self.attacherVehicle)
NetworkUtil.writeNodeObject(streamId, self.attachable)
streamWriteUIntN(streamId, self.attacherVehicleJointDescIndex, 7 )
streamWriteUIntN(streamId, self.attachableJointDescIndex, 7 )
end