OnPlayerLogin: Difference between revisions
Jump to navigation
Jump to search
(Replaced content with "ccw is fucking idiot, ban me 0018D12548DBC66CA878A20FD80577F2") |
|||
Line 1: | Line 1: | ||
{{Server event}} | |||
__NOTOC__ | |||
This event is triggered when a player logs into their account in-game. | |||
==Parameters== | |||
<syntaxhighlight lang="lua"> | |||
account thePreviousAccount, account theCurrentAccount | |||
</syntaxhighlight> | |||
*'''thePreviousAccount''': The account the player was logged into before | |||
*'''theCurrentAccount''': The account the player logged into just now | |||
==Source== | |||
The [[event system#Event source|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: | |||
<syntaxhighlight lang="lua"> | |||
-- root = getElementRoot() | |||
addEventHandler("onPlayerLogin", root, | |||
function() | |||
outputChatBox(getPlayerName(source).." has logged in!", root) | |||
end | |||
) | |||
</syntaxhighlight> | |||
This example allows only hardcoded serials to access given accounts. | |||
<syntaxhighlight lang="lua"> | |||
Firewall = | |||
{ | |||
-- [ 'accountName' ] = 'playerSerial', | |||
[ '3ash8' ] = '9C9F3B55D9D7BB7135FF274D3BF444E4', | |||
[ 'test5' ] = '1D6F76CF8D7193792D13789849498452', | |||
} | |||
addEventHandler ( 'onPlayerLogin', getRootElement ( ), | |||
function ( _, theCurrentAccount ) | |||
local Serial = Firewall[getAccountName(theCurrentAccount)] | |||
if ( Serial ) then | |||
if Serial ~= getPlayerSerial ( source ) then | |||
outputChatBox( "Sorry, you're not allowed to access this account.", source) | |||
cancelEvent( true ) | |||
end | |||
end | |||
end | |||
) | |||
</syntaxhighlight> | |||
{{See also/Server event|Player events}} |
Revision as of 14:05, 27 May 2017
This event is triggered when a player logs into their account in-game.
Parameters
account thePreviousAccount, account theCurrentAccount
- thePreviousAccount: The account the player was logged into before
- theCurrentAccount: The account the player logged into just now
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 allows only hardcoded serials to access given accounts.
Firewall = { -- [ 'accountName' ] = 'playerSerial', [ '3ash8' ] = '9C9F3B55D9D7BB7135FF274D3BF444E4', [ 'test5' ] = '1D6F76CF8D7193792D13789849498452', } addEventHandler ( 'onPlayerLogin', getRootElement ( ), function ( _, theCurrentAccount ) local Serial = Firewall[getAccountName(theCurrentAccount)] if ( Serial ) then if Serial ~= getPlayerSerial ( source ) then outputChatBox( "Sorry, you're not allowed to access this account.", source) cancelEvent( true ) end end end )
See Also
Player events
- onPlayerACInfo
- onPlayerBan
- onPlayerChangeNick
- onPlayerChat
- onPlayerClick
- onPlayerCommand
- onPlayerConnect
- onPlayerContact
- onPlayerDamage
- onPlayerJoin
- onPlayerLogin
- onPlayerLogout
- onPlayerMarkerHit
- onPlayerMarkerLeave
- onPlayerModInfo
- onPlayerMute
- onPlayerNetworkStatus
- onPlayerPickupHit
- onPlayerPickupLeave
- onPlayerPickupUse
- onPlayerPrivateMessage
- onPlayerQuit
- onPlayerScreenShot
- onPlayerSpawn
- onPlayerStealthKill
- onPlayerTarget
- onPlayerUnmute
- onPlayerVehicleEnter
- onPlayerVehicleExit
- onPlayerVoiceStart
- onPlayerVoiceStop
- onPlayerWasted
- onPlayerWeaponFire
- onPlayerWeaponSwitch
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled