Skip to main content
Skip to main content

SetCruiseControlSpeedEvent

SetCruiseControlSpeedEvent

Description

Event for cruise control speed

Parent

Event

Functions

emptyNew

Description

Create instance of Event class

Definition

emptyNew()

Return Values

anyselfinstance of class event

Code

function SetCruiseControlSpeedEvent.emptyNew()
local self = Event.new( SetCruiseControlSpeedEvent _mt)
return self
end

new

Description

Create new instance of event

Definition

new(table vehicle, float speed, float speedReverse)

Arguments

tablevehiclevehicle
floatspeedspeed
floatspeedReversespeedReverse

Code

function SetCruiseControlSpeedEvent.new(vehicle, speed, speedReverse)
local self = SetCruiseControlSpeedEvent.emptyNew()
self.speed = speed
self.speedReverse = speedReverse
self.vehicle = vehicle
return self
end

readStream

Description

Called on client side on join

Definition

readStream(integer streamId, Connection connection)

Arguments

integerstreamIdstreamId
Connectionconnectionconnection

Code

function SetCruiseControlSpeedEvent:readStream(streamId, connection)
self.vehicle = NetworkUtil.readNodeObject(streamId)
self.speed = streamReadUInt8(streamId)
self.speedReverse = streamReadUInt8(streamId)
self:run(connection)
end

run

Description

Run action on receiving side

Definition

run(Connection connection)

Arguments

Connectionconnectionconnection

Code

function SetCruiseControlSpeedEvent:run(connection)
if not connection:getIsServer() then
g_server:broadcastEvent( self , false , connection, self.vehicle)
end
if self.vehicle ~ = nil and self.vehicle:getIsSynchronized() then
self.vehicle:setCruiseControlMaxSpeed( self.speed, self.speedReverse)
end
end

writeStream

Description

Called on server side on join

Definition

writeStream(integer streamId, Connection connection)

Arguments

integerstreamIdstreamId
Connectionconnectionconnection

Code

function SetCruiseControlSpeedEvent:writeStream(streamId, connection)
NetworkUtil.writeNodeObject(streamId, self.vehicle)
streamWriteUInt8(streamId, self.speed)
streamWriteUInt8(streamId, self.speedReverse)
end