GetTrainTrack: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (shared)
No edit summary
Line 17: Line 17:


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler("getTrain",
addCommandHandler("traintrack",
function ()
function (player)
local thePlayer = getLocalPlayer()
  if isPedInVehicle (player) then
local theVehicle = getPedOccupiedVehicle(thePlayer)
      local theVehicle = getPedOccupiedVehicle(player)
train = getTrainTrack(theVehicle)
      if getVehicleType(theVehicle) == "Train" then
outputChatBox("Train Track is "..train)
  local track = getTrainTrack(theVehicle)
end)
  outputChatBox("Train Track is "..track,player,0,255,0)
 
      end
  end
end
)
</syntaxhighlight>
</syntaxhighlight>


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

Revision as of 00:16, 30 July 2016

Gets the track of a train

Syntax

int getTrainTrack ( vehicle train )

OOP Syntax Help! I don't understand this!

Method: vehicle:getTrack(...)
Variable: .track
Counterpart: setTrainTrack


Required Arguments

  • train: the train of which to get the track.

Returns

Returns an integer (whole number) that represents the train track, false if there is problem with train element.

Example

addCommandHandler("traintrack",
function (player)
   if isPedInVehicle (player) then
      local theVehicle = getPedOccupiedVehicle(player)
      if getVehicleType(theVehicle) == "Train" then
	  local track = getTrainTrack(theVehicle)
	  outputChatBox("Train Track is "..track,player,0,255,0)
      end
   end
end
)

See Also