GetPlayerUserName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 4: Line 4:


==Syntax==
==Syntax==
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string getPlayerUserName ( player thePlayer )
string getPlayerUserName ( player thePlayer )
</syntaxhighlight>
</syntaxhighlight>  
===Required Arguments===
*'''thePlayer:''' The Player whose MTA account username you want to retrieve


===Required Arguments===
===Returns===
*'''thePlayer:''' The Player which's MTA-Account you want to retrieve
A ''string'' value containing the MTA account username or ''false'' if no account exists for the player.
</section>


<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
string getPlayerUserName ()
</syntaxhighlight>
===Returns===
===Returns===
A ''string'' value containing the MTA-Account-Name or ''false'' if there is no account with that serial existing.
A ''string'' value containing the local MTA accounts username or ''false'' if no account exists for the local player.
</section>


==Example==
==Example==

Revision as of 21:12, 5 February 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 the local MTA accounts username or false if no account exists for the local player.

Example

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 )