GetPlayerUserName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server function}}
{{Server client function}}
This function returns the community.mtasa.com (or mtabeta.com)-Account of the specified user.
This function returns the community.mtasa.com (or mtabeta.com) account of the specified user.


==Syntax==
==Syntax==
Line 9: Line 9:
</syntaxhighlight>  
</syntaxhighlight>  
===Required Arguments===  
===Required Arguments===  
*'''thePlayer:''' The Player whose MTA account username you want to retrieve
*'''thePlayer:''' The [[player]] whose MTA account username you want to retrieve.


===Returns===
===Returns===
Line 20: Line 20:
</syntaxhighlight>  
</syntaxhighlight>  
===Returns===
===Returns===
A ''string'' value containing the local MTA accounts username or ''false'' if no account exists for the local player.
A ''string'' value containing local player's MTA account username or ''false'' if no account exists for the local player.
</section>
</section>


Line 31: Line 31:
                 local mtaaccount = getPlayerUserName( sourcePlayer )
                 local mtaaccount = getPlayerUserName( sourcePlayer )
                 if( mtaaccount ) then
                 if( mtaaccount ) then
                         outputChatBox("Your community.mtasa.com-Account is " .. mtaaccount, sourcePlayer )
                         outputChatBox("Your community.mtasa.com account is " .. mtaaccount, sourcePlayer )
                 else
                 else
                         outputChatBox("Can't find an account for you.", sourcePlayer )
                         outputChatBox("Can't find an account for you.", sourcePlayer )
Line 43: Line 43:
</syntaxhighlight>  
</syntaxhighlight>  
</section>
</section>
==See Also==
===Client===
{{Client serial functions}}
===Server===
{{Serial functions}}

Revision as of 15:24, 4 May 2008

This function returns the community.mtasa.com (or mtabeta.com) account of the specified user.

Syntax

Click to collapse [-]
Server
string getPlayerUserName ( player thePlayer )

Required Arguments

  • thePlayer: The player whose MTA account username you want to retrieve.

Returns

A string value containing the MTA account username or false if no account exists for the player.

Click to collapse [-]
Client
string getPlayerUserName ()

Returns

A string value containing local player's MTA account username or false if no account exists for the local player.

Example

Click to collapse [-]
Server
function outputMTAAccount ( sourcePlayer )
        -- if the command was triggered by an ingame player
        if ( sourcePlayer ) then
                local mtaaccount = getPlayerUserName( sourcePlayer )
                if( mtaaccount ) then
                        outputChatBox("Your community.mtasa.com account is " .. mtaaccount, sourcePlayer )
                else
                        outputChatBox("Can't find an account for you.", sourcePlayer )
                end
        end
end


-- register outputMTAAccount as a handler for the mta-account command
addCommandHandler ( "mta-account", outputMTAAccount )

See Also

Client

Server