From Multi Theft Auto: Wiki
Revision as of 12:29, 7 October 2018 by Surge (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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


element getPedContactElement ( ped thePed )

OOP Syntax Help! I don't understand this!

Method: ped:getContactElement(...)
Variable: .contactElement

Required Arguments

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


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.


Click to collapse [-]

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 and getElementType ( elementStandingOn ) == "vehicle" then
        local vehicleName = getVehicleName ( elementStandingOn )
        outputChatBox( "You're standing on a " .. vehicleName .. "." )
        outputChatBox( "You're not standing on any vehicle." )

See Also