IsGuestAccount: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Checked, slight changes)
Line 16: Line 16:
This example shows how you could create a ''call_admin'' function that only could be run by registered users.
This example shows how you could create a ''call_admin'' function that only could be run by registered users.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler ( "call_admin", callAdmin )
function callAdmin ( playerSource )
function callAdmin ( playerSource, commandName )
     -- get the account of the user trying to use this function first
     sourceAccount = getClientAccount ( playerSource ) -- get the account for the user trying to use this function
     sourceAccount = getClientAccount ( playerSource )
     if ( isGuestAccount ( sourceAccount ) == true ) then -- see if they're a guest
    -- if they're a guest
         outputConsole ( "Please register to use this function!", playerSource ) -- if they are, tell them to register
    if isGuestAccount ( sourceAccount ) then
        -- tell them to register
         outputConsole ( "Please register to use this function!", playerSource )
     else
     else
         -- Your code here
         -- your code to call the admin would go here
     end
     end
end
end
-- attach the function 'callAdmin' as a handler to the command "call_admin"
addCommandHandler ( "call_admin", callAdmin )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Account_functions}}
{{Account_functions}}

Revision as of 16:45, 31 July 2007

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.

Syntax

bool isGuestAccount ( account theAccount )

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 = getClientAccount ( 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