SetTrainTrack: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (shared)
m (delete -> disabled)
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Shared function}}
{{Shared function}}
{{Disabled}}
{{New feature/item|3.0160|1.6|7485|
{{New feature/item|3.0160|1.6|7485|
Sets the track of a train
Sets the track of a train
Line 22: Line 23:
local theVehicle = getPedOccupiedVehicle(player)
local theVehicle = getPedOccupiedVehicle(player)
if not theVehicle then
if not theVehicle then
outputChatBox("You are not in a vehicle!")
outputChatBox("You are not in a vehicle!", player)
return
return
end
end
Line 29: Line 30:
setTrainTrack(theVehicle, track)
setTrainTrack(theVehicle, track)
else
else
outputChatBox("You are not in a train!")
outputChatBox("You are not in a train!", player)
end
end
end
end
)
)
</syntaxhighlight></section>
</syntaxhighlight></section>
<section name="Object Orientated" class="server"><syntaxhighlight lang="lua">
<section name="Object Oriented" class="server"><syntaxhighlight lang="lua">
addCommandHandler("trackies",
addCommandHandler("trackies",
function (player, _, track)
function (player, _, track)
local veh = player.vehicle
local veh = player.vehicle
if not veh then
if not veh then
return outputChatBox("You are not in a vehicle!")
return player:outputChat("You are not in a vehicle!")
end
end


Line 45: Line 46:
veh.track = track
veh.track = track
else
else
outputChatBox("You are not in a train!")
player:outputChat("You are not in a train!")
end
end
end
end

Latest revision as of 19:38, 19 May 2019

Dialog-warning.png Function has been disabled.

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 Oriented

See Also