IsGuestAccount: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(OOP syntax added)
m (→‎Syntax: OOP)
Line 6: Line 6:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool isGuestAccount ( account theAccount )
bool isGuestAccount ( account theAccount )
</syntaxhighlight>  
</syntaxhighlight>
{{OOP||[[account]]:isGuest|guest|}}
{{OOP|This function is also a static function underneath the Account class.|[[account]]:isGuest|guest|}}  
===Required Arguments===  
===Required Arguments===  
*'''theAccount:''' The account you want to check to see if it is a guest account.
*'''theAccount:''' The account you want to check to see if it is a guest account.

Revision as of 16:11, 22 August 2014

This function checks to see if an account is a guest account. A guest account is an account automatically created for a user when they join the server and deleted when they quit or login to another account. Data stored in a guest account is not stored after the player has left the server. As a consequence, this function will check if a player is logged in or not.

Syntax

bool isGuestAccount ( account theAccount )

OOP Syntax Help! I don't understand this!

Note: This function is also a static function underneath the Account class.
Method: account:isGuest(...)
Variable: .guest


Required Arguments

  • theAccount: The account you want to check to see if it is a guest account.

Returns

Returns true if the account is a guest account, false otherwise.

Example

This example shows how you could create a call_admin function that only could be run by registered users.

function callAdmin ( playerSource )
    -- get the account of the user trying to use this function first
    sourceAccount = getPlayerAccount ( playerSource )
    -- if they're a guest
    if isGuestAccount ( sourceAccount ) then
        -- tell them to register
        outputConsole ( "Please register to use this function!", playerSource )
    else
        -- your code to call the admin would go here
    end
end
-- attach the function 'callAdmin' as a handler to the command "call_admin"
addCommandHandler ( "call_admin", callAdmin )

See Also