GetPlayerContactElement: Difference between revisions
Jump to navigation
Jump to search
(New page: __NOTOC__ {{Client function}} <!-- Describe in plain english what this function does. Don't go into details, just give an overview --> This function detects the vehicle a player is standi...) |
m (Changed "DeprecatedWithAlt" template to "Deprecated") |
||
(5 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{ | {{Server client function}} | ||
{{Deprecated|getPedContactElement|}} | |||
This function detects the | |||
This function detects the element a player is standing on. This can be a vehicle or an object. Note that the server is unable to retrieve contact elements that are created clientside. | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
element getPlayerContactElement ( player thePlayer ) | element getPlayerContactElement ( player thePlayer ) | ||
Line 11: | Line 11: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''thePlayer:''' The [[player]] you want to get the [[element]] he is touching from. | |||
*'''thePlayer:''' The player you want to get the | |||
===Returns=== | ===Returns=== | ||
Returns an [[object]] or a [[vehicle]] if the player is standing on one, ''false'' if he is touching none or is a invalid player. | |||
Returns a [[vehicle]] if the player is | |||
==Example== | ==Example== | ||
This clientside function outputs the name of the vehicle the specified player is standing on, or a message saying he isn't on one. | |||
This | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local | function outputContactVehicleMessage ( thePlayer ) | ||
local | local elementStandingOn = getPlayerContactElement( thePlayer ) | ||
outputChatBox( | if getElementType( elementStandingOn ) == "vehicle" then | ||
local vehicleName = getVehicleName( elementStandingOn ) | |||
outputChatBox( "The player is standing on a " .. vehicleName .. "." ) | |||
else | |||
outputChatBox( "The player isn't standing on any vehicle." ) | |||
end | |||
end | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Player functions}} | {{Player functions}} |
Latest revision as of 16:30, 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 getPedContactElement instead. |
This function detects the element a player is standing on. This can be a vehicle or an object. Note that the server is unable to retrieve contact elements that are created clientside.
Syntax
element getPlayerContactElement ( player thePlayer )
Required Arguments
Returns
Returns an object or a vehicle if the player is standing on one, false if he is touching none or is a invalid player.
Example
This clientside function outputs the name of the vehicle the specified player is standing on, or a message saying he isn't on one.
function outputContactVehicleMessage ( thePlayer ) local elementStandingOn = getPlayerContactElement( thePlayer ) if getElementType( elementStandingOn ) == "vehicle" then local vehicleName = getVehicleName( elementStandingOn ) outputChatBox( "The player is standing on a " .. vehicleName .. "." ) else outputChatBox( "The player isn't standing on any vehicle." ) end end
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