GetPedContactElement: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Server client function}}
This function detects the element a ped is standing on. This can be a vehicle or an object.
This function detects the element a ped is standing on. This can be a vehicle or an object.


Line 29: Line 29:


==See Also==
==See Also==
{{Client_ped_functions}}
{{Ped functions}}

Revision as of 20:00, 25 May 2008

This function detects the element a ped is standing on. This can be a vehicle or an object.

Syntax

element getPedContactElement ( ped thePed )

Required Arguments

  • thePed: The ped of which you want to get the element he is standing on.

Returns

Returns an object or a vehicle if the ped is standing on one, false if he is touching none or an invalid element was passed.

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 = getPedContactElement( thePlayer )
    if elementStandingOn ~= false and 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