GetAccountPlayer

From Multi Theft Auto: Wiki
Revision as of 16:58, 28 March 2009 by Awwu (talk | contribs) (New page: __NOTOC__ {{Server function}} This function returns the player element that is currently using a specified account, i.e. is logged into it. Only one player can use an account at a...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function returns the player element that is currently using a specified account, i.e. is logged into it. Only one player can use an account at a time.

Syntax

player getAccountPlayer ( account theAccount )

Required Arguments

Returns

Returns a player element if the account is currently in use, false otherwise.

Example

This example checks if the user attached to an account is a player, and if so if they're alive.

function isAccountUserAlive ( theAccount )
    local thePlayer = getAccountPlayer ( theAccount )       -- get the client attached to the account
    if ( getElementType ( thePlayer ) == "player" ) then    -- see if it really is a player (rather than a console admin for example)
        if ( not isPlayerDead ( thePlayer ) ) then          -- if the player's health is greater than 0 
            return true
        end
    end
    return false
end

See Also