GetPlayerOccupiedVehicle: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
==Syntax== | ==Syntax== | ||
<section name="Server" class="server" show="true"> | |||
<syntaxhighlight lang="lua">vehicle getPlayerOccupiedVehicle ( player thePlayer )</syntaxhighlight> | <syntaxhighlight lang="lua">vehicle getPlayerOccupiedVehicle ( player thePlayer )</syntaxhighlight> | ||
Line 11: | 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 player is in, or ''false'' if the player is not in a vehicle or is an invalid player. | ||
</section> | |||
<section name="Client" class="client"> | |||
<syntaxhighlight lang="lua">vehicle getPlayerOccupiedVehicle ( )</syntaxhighlight> | |||
===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. | |||
</section> | |||
==Example== | ==Example== | ||
This example outputs the vehicle name of the vehicle if the player is currently occupying one, when he enters the 'vehicleName' command. | This example outputs the vehicle name of the vehicle if the player is currently occupying one, when he enters the 'vehicleName' command. | ||
<section name="Server" class="server" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function showVehicleName(player) | function showVehicleName(player) | ||
Line 24: | Line 36: | ||
addCommandHandler("vehicleName",showVehicleName) | addCommandHandler("vehicleName",showVehicleName) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
This example outputs the vehicle name of the vehicle if the player is currently occupying one, when he enters the 'vehicleName' command. | |||
<section name="Client" class="client"> | |||
<syntaxhighlight lang="lua"> | |||
function showVehicleName() | |||
local vehicle = getPlayerOccupiedVehicle() | |||
if (vehicle ~= false) then | |||
local vehicleName = getVehicleName(vehicle) | |||
outputChatBox("Vehicle name: "..vehicleName,player) | |||
end | |||
end | |||
addCommandHandler("vehicleName",showVehicleName) | |||
</syntaxhighlight> | |||
</section> | |||
==See Also== | ==See Also== | ||
{{Player functions}} | {{Player functions}} |
Revision as of 11:55, 7 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 player is in, or false if the player is not in a vehicle or is an invalid player.
Click to expand [+]
ClientExample
This example outputs the vehicle name of the vehicle if the player is currently occupying one, when he enters the 'vehicleName' command.
Click to collapse [-]
Serverfunction showVehicleName(player) local vehicle = getPlayerOccupiedVehicle(player) if (vehicle ~= false) then local vehicleName = getVehicleName(vehicle) outputChatBox("Vehicle name: "..vehicleName,player) end end addCommandHandler("vehicleName",showVehicleName)
This example outputs the vehicle name of the vehicle if the player is currently occupying one, when he enters the 'vehicleName' command. <section name="Client" class="client">
function showVehicleName() local vehicle = getPlayerOccupiedVehicle() if (vehicle ~= false) then local vehicleName = getVehicleName(vehicle) outputChatBox("Vehicle name: "..vehicleName,player) 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