GetPlayerAccount: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
{{Needs Checking|Should this page be removed, as the function doesn't seem to be implented at all? There's already [[getClientAccount]]. --[[User:Awwu|Awwu]] 08:57, 5 April 2008 (CDT)}}
__NOTOC__
__NOTOC__  
{{Server function}}
{{Server function}}
Returns the accountname of the player
This function returns the specified player's [[account]] object.


==Syntax==  
==Syntax==
<syntaxhighlight lang="lua">string getPlayerAccount ( player thePlayer )</syntaxhighlight>  
<syntaxhighlight lang="lua">
account getPlayerAccount ( player thePlayer )
</syntaxhighlight>


===Required Arguments===  
===Required Arguments===
*'''thePlayer:''' The player you wish the retrieve the name of the account from.
* '''thePlayer:''' The [[player]] element you want to get the [[account]] of.


===Returns===
===Returns===
Returns an string with name of the account.
Returns the player's account object, or ''false'' if the player passed to the function is invalid.
-- TODO -- What does it return if it isnt known?


==Example==
==Example==
When a player types '/account' this example retrieves the player's accountname, and prints it to his screen.
This example sets a player's money and also stores the value is his account.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function viewAccount(thePlayer, command)
function setMoney ( thePlayer, key, amount )
-- get the name of the account from thePlayer
    setPlayerMoney ( thePlayer, amount )
local accountName = getPlayerAccount(thePlayer)  
    local account = getPlayerAccount ( thePlayer )
    if ( account ) then
-- output the message to the player
        setAccountData ( account, "money", amount )
outputChatBox("Your account name is " .. accountName, thePlayer)
    end
end
end
 
addCommandHandler ( "setmoney", setMoney )
-- add the console command
addCommandHandler("account", viewAccount)                                  
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Player functions}}
{{Player functions}}
[[Category:Incomplete]]

Revision as of 14:33, 27 March 2009

This function returns the specified player's account object.

Syntax

account getPlayerAccount ( player thePlayer )

Required Arguments

Returns

Returns the player's account object, or false if the player passed to the function is invalid.

Example

This example sets a player's money and also stores the value is his account.

function setMoney ( thePlayer, key, amount )
    setPlayerMoney ( thePlayer, amount )
    local account = getPlayerAccount ( thePlayer )
    if ( account ) then
        setAccountData ( account, "money", amount )
    end
end
addCommandHandler ( "setmoney", setMoney )

See Also