GetPlayerOccupiedVehicle: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 11: | Line 11: | ||
===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. | ||
</section> | </section> | ||
<section name="Client" class="client"> | <section name="Client" class="client" show="true"> | ||
<syntaxhighlight lang="lua">vehicle getPlayerOccupiedVehicle ( )</syntaxhighlight> | <syntaxhighlight lang="lua">vehicle getPlayerOccupiedVehicle ( )</syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
''None'' | |||
===Returns=== | ===Returns=== | ||
Returns the vehicle that the player is in, or ''false'' if the player is not in a vehicle | Returns the vehicle that the local player is in, or ''false'' if the player is not in a vehicle. | ||
</section> | </section> | ||
==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" class="server" show="true"> | <section name="Server" class="server" 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> | |||
<section name="Client" class="client" show="true"> | |||
<section name="Client" class="client"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function showVehicleName() | function showVehicleName ( thePlayer ) | ||
local theVehicle = getPlayerOccupiedVehicle ( ) | |||
local | if ( theVehicle ) then | ||
if ( | local vehicleName = getVehicleName ( theVehicle ) | ||
local vehicleName = getVehicleName( | outputChatBox ( "Vehicle name: " .. vehicleName, thePlayer ) | ||
outputChatBox("Vehicle name: "..vehicleName, | |||
end | end | ||
end | end | ||
addCommandHandler(" | addCommandHandler ( "vehiclename", showVehicleName ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> |
Revision as of 14:44, 19 August 2007
This function gets the vehicle that the player is currently in, if any.
Syntax
Click to collapse [-]
Servervehicle 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.
Click to collapse [-]
Clientvehicle getPlayerOccupiedVehicle ( )
Required Arguments
None
Returns
Returns the vehicle that the local player is in, or false if the player is not in a vehicle.
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 [-]
Serverfunction showVehicleName ( thePlayer ) local theVehicle = getPlayerOccupiedVehicle ( thePlayer ) if ( theVehicle ) then local vehicleName = getVehicleName ( theVehicle ) outputChatBox ( "Vehicle name: " .. vehicleName, thePlayer ) end end addCommandHandler ( "vehiclename", showVehicleName )
Click to collapse [-]
Clientfunction showVehicleName ( thePlayer ) local theVehicle = getPlayerOccupiedVehicle ( ) 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