SetTrainTrack: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(rewrite example)
m (add oop example!)
Line 17: Line 17:
==Example==
==Example==
This server-side script allows the player to change the track of their train.
This server-side script allows the player to change the track of their train.
<syntaxhighlight lang="lua">
<section name="Procedural"><syntaxhighlight lang="lua">
addCommandHandler("trackies",
addCommandHandler("trackies",
function (player, _, track)
function (player, _, track)
Line 33: Line 33:
end
end
)
)
</syntaxhighlight>
</syntaxhighlight></section>
<section name="Object Orientated"><syntaxhighlight lang="lua">
addCommandHandler("trackies",
function (player, _, track)
local veh = player.vehicle
if not veh then
return outputChatBox("You are not in a vehicle!")
end
 
if veh.vehicleType == "Train" then
veh.track = track
else
outputChatBox("You are not in a train!")
end
end
)
</syntaxhighlight></section>


==See Also==
==See Also==
{{Vehicle functions}}
{{Vehicle functions}}

Revision as of 19:38, 29 December 2015

Sets the track of a train

Syntax

bool setTrainTrack ( vehicle train, int track )

OOP Syntax Help! I don't understand this!

Method: vehicle:setTrack(...)
Variable: .track
Counterpart: getTrainTrack


Required Arguments

  • train: the train of which to set the track
  • track: the track where you want to set the train. It can be 0, 1, 2 or 3.

Returns

Returns true if the track was set to the train, false otherwise.

Example

This server-side script allows the player to change the track of their train.

Click to expand [+]
Procedural
Click to expand [+]
Object Orientated

See Also