OnPlayerLogin: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 28: Line 28:
)
)
</syntaxhighlight>
</syntaxhighlight>
 
This example is Firewall Account Player by serial on Login
<syntaxhighlight lang="lua">
Firewall =
{
    [ 'AccountName' ] = 'SerialPlayer',
    [ '3ash8' ] = '9C9F3B55D9D7BB7135FF274D3BF444E4',
    [ 'test5' ] = '1D6F76CF8D7193792D13789849498452',
}
addEventHandler ( 'onPlayerLogin', getRootElement ( ),
    function ( _, theCurrentAccount )
    local Serial = Firewall[getAccountName(theCurrentAccount)]
        if ( Serial ) then
            if Serial ~= getPlayerSerial ( source ) then
                banPlayer ( source, false, false, true, getRootElement ( ), 'reason ban' )
            end
        end
    end
)
</syntaxhighlight>
{{See also/Server event|Player events}}
{{See also/Server event|Player events}}

Revision as of 07:24, 15 December 2012

This event is triggered when a player logs into their account in-game.

Parameters

account thePreviousAccount, account theCurrentAccount, bool autoLogin
  • thePreviousAccount: The account the player was logged into before
  • theCurrentAccount: The account the player logged into just now
  • autoLogin: Whether this login was a result of an autologin

Source

The source of this event is the player element that just logged in.

Cancel effect

If this event is canceled the player will not be logged in.

Example

This example just outputs to the player console that a player in one account logged into an another account:

-- root = getElementRoot()
addEventHandler("onPlayerLogin", root,
  function()
    outputChatBox(getPlayerName(source).." has logged in!", root)
  end
)

This example is Firewall Account Player by serial on Login

Firewall = 
{
    [ 'AccountName' ] = 'SerialPlayer',
    [ '3ash8' ] = '9C9F3B55D9D7BB7135FF274D3BF444E4',
    [ 'test5' ] = '1D6F76CF8D7193792D13789849498452',
}
 
addEventHandler ( 'onPlayerLogin', getRootElement ( ),
    function ( _, theCurrentAccount )
    local Serial = Firewall[getAccountName(theCurrentAccount)]
        if ( Serial ) then
            if Serial ~= getPlayerSerial ( source ) then
                banPlayer ( source, false, false, true, getRootElement ( ), 'reason ban' )
            end
        end
    end
)

See Also

Player events


Event functions