IsPlayerInVehicle: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 6: | Line 6: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''thePlayer''': The [[player]] element you are checking. | ||
===Returns=== | ===Returns=== | ||
Line 14: | Line 14: | ||
This code defines an ''isinvehicle'' command which tells a player whether another player is in a vehicle or not. | This code defines an ''isinvehicle'' command which tells a player whether another player is in a vehicle or not. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- we create our handler function, where sourcePlayer is the player who sent the command, | -- we create our handler function, where sourcePlayer is the player who sent the command, | ||
-- and checkedPlayerName is the player name specified. | -- and checkedPlayerName is the player name specified. | ||
Line 39: | Line 36: | ||
end | end | ||
end | end | ||
-- define a handler for the isinvehicle command | |||
addCommandHandler ( "isinvehicle", outputIsInVehicle ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Player functions}} | {{Player functions}} |
Revision as of 18:34, 30 July 2007
This function checks if a player is in a vehicle.
Syntax
bool isPlayerInVehicle ( player thePlayer )
Required Arguments
- thePlayer: The player element you are checking.
Returns
Returns true if the player is inside a vehicle, false if he isn't or an invalid player was passed.
Example
This code defines an isinvehicle command which tells a player whether another player is in a vehicle or not.
-- we create our handler function, where sourcePlayer is the player who sent the command, -- and checkedPlayerName is the player name specified. function outputIsInVehicle ( sourcePlayer, commandName, checkedPlayerName ) -- we get the player element from the nick specified local checkedPlayer = getPlayerFromNick ( checkedPlayerName ) -- if it exists, if ( checkedPlayer ) then -- if it's in a vehicle, if isPlayerInVehicle ( checkedPlayer ) then -- tell the source player outputChatBox ( checkedPlayerName .. " is in a vehicle.", sourcePlayer ) -- if it's not in a vehicle, else -- tell the source player outputChatBox ( checkedPlayerName .. " is not in a vehicle.", sourcePlayer ) end -- if it doesn't exist, else -- tell the source player outputChatBox ( "Invalid player name.", sourcePlayer ) end end -- define a handler for the isinvehicle command addCommandHandler ( "isinvehicle", outputIsInVehicle )
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