GetPlayerOccupiedVehicle: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
==Description==
This function gets the [[vehicle]] that the player is currently in, if any.
This function returns a [[vehicle]] that the player is currently in, if any. This function returns false if the player is on foot, or the player doesn't exist.


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">vehicle getPlayerOccupiedVehicle ( player player )</syntaxhighlight>
<syntaxhighlight lang="lua">vehicle getPlayerOccupiedVehicle ( player thePlayer )</syntaxhighlight>


===Required Arguments===
===Required Arguments===
*'''player''': The [[player]] whose vehicle you're looking up.
*'''thePlayer''': The [[player]] whose vehicle you're looking up.
 
===Returns===
Returns the vehicle that the player is in, or ''false'' if the player is not in a vehicle or is an invalid player.


==Example==
==Example==
<syntaxhighlight lang="lua">if ( vehicle = getPlayerOccupiedVehicle ( findPlayer ( "Someguy" ) ) )
This example finds if the player called ''someguy'' is in a vehicle, if they it shows the vehicle's health in the chatbox.
   OutputChatBox ( "Someguy is in a vehicle with ", getVehicleHealth ( vehicle ), " health." )
<syntaxhighlight lang="lua">if ( vehicle = getPlayerOccupiedVehicle ( findPlayer ( "someguy" ) ) )
   outputChatBox ( "Someguy is in a vehicle with " .. getVehicleHealth ( vehicle ) .. " health." )
else
else
   Outputchatbox ( "Someguy is not in a vehicle." )
   outputchatbox ( "Someguy is not in a vehicle." )
end</syntaxhighlight>
end</syntaxhighlight>


==See Also==
==See Also==
{{Player functions}}
{{Player functions}}

Revision as of 11:14, 14 August 2006

This function gets the vehicle that the player is currently in, if any.

Syntax

vehicle getPlayerOccupiedVehicle ( player thePlayer )

Required Arguments

  • thePlayer: The player whose vehicle you're looking up.

Returns

Returns the vehicle that the player is in, or false if the player is not in a vehicle or is an invalid player.

Example

This example finds if the player called someguy is in a vehicle, if they it shows the vehicle's health in the chatbox.

if ( vehicle = getPlayerOccupiedVehicle ( findPlayer ( "someguy" ) ) )
  outputChatBox ( "Someguy is in a vehicle with " .. getVehicleHealth ( vehicle ) .. " health." )
else
  outputchatbox ( "Someguy is not in a vehicle." )
end

See Also

Shared