GetPlayerOccupiedVehicle: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Changed "DeprecatedWithAlt" template to "Deprecated") |
||
(6 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
{{Deprecated|getPedOccupiedVehicle|}} | |||
This function gets the [[vehicle]] that the player is currently in, if any. | This function gets the [[vehicle]] that the player is currently in, if any. | ||
Line 10: | Line 12: | ||
===Returns=== | ===Returns=== | ||
Returns the vehicle that the player is in, or ''false'' if the player is not in a vehicle or is an invalid player. | Returns the vehicle that the specified player is in, or ''false'' if the player is not in a vehicle or is an invalid player. | ||
==Example== | ==Example== | ||
When a player enters the 'vehiclename' command and is currently in a vehicle, this example outputs the name of the vehicle. | |||
<section name="Server and client" class="both" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function showVehicleName( | function showVehicleName ( thePlayer ) | ||
local | local theVehicle = getPlayerOccupiedVehicle ( thePlayer ) | ||
if ( | if ( theVehicle ) then | ||
local vehicleName = getVehicleName( | local vehicleName = getVehicleName ( theVehicle ) | ||
outputChatBox("Vehicle name: "..vehicleName, | outputChatBox ( "Vehicle name: " .. vehicleName, thePlayer ) | ||
end | end | ||
end | end | ||
addCommandHandler(" | addCommandHandler ( "vehiclename", showVehicleName ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{Player functions}} | {{Player functions}} |
Latest revision as of 16:13, 13 February 2015
This function is deprecated. This means that its use is discouraged and that it might not exist in future versions. | |
Please use getPedOccupiedVehicle instead. |
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 specified player is in, or false if the player is not in a vehicle or is an invalid player.
Example
When a player enters the 'vehiclename' command and is currently in a vehicle, this example outputs the name of the vehicle.
Click to collapse [-]
Server and clientfunction showVehicleName ( thePlayer ) local theVehicle = getPlayerOccupiedVehicle ( thePlayer ) if ( theVehicle ) then local vehicleName = getVehicleName ( theVehicle ) outputChatBox ( "Vehicle name: " .. vehicleName, thePlayer ) end end addCommandHandler ( "vehiclename", showVehicleName )
See Also
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState