LogOut: Difference between revisions
Jump to navigation
Jump to search
m (Removed "Needs example" category.) |
m (Добавление языков) |
||
(13 intermediate revisions by 10 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server function}} | {{Server function}} | ||
This function logs the given player out of his current account. | This function logs the given player out of his current [[account]]. | ||
==Syntax== | ==Syntax== | ||
Line 7: | Line 7: | ||
bool logOut ( player thePlayer ) | bool logOut ( player thePlayer ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[player]]:logOut}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 15: | Line 16: | ||
==Example== | ==Example== | ||
This example logs every player out of their account when the resource is (re)started. This would be handy for resources that show a login | This example logs every player out of their account when the resource is (re)started. This would be handy for resources that show a login screen onClientResourceStart. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function logoutAll () | function logoutAll () | ||
local players = getElementsByType ( "player" ) | local players = getElementsByType ( "player" ) -- Get every player | ||
for k, player in ipairs ( players ) do | for k, player in ipairs ( players ) do -- For every player do the following... | ||
account = getPlayerAccount ( player ) | account = getPlayerAccount ( player ) -- Get every player's account | ||
if ( not isGuestAccount ( account ) ) then | if ( not isGuestAccount ( account ) ) then -- For every player that's logged in.... | ||
logOut ( player ) | logOut ( player ) -- Log them out. | ||
end | end | ||
end | end | ||
end | end | ||
addEventHandler ( "onResourceStart", getResourceRootElement | -- Trigger it when the resource (re)starts | ||
</syntaxhighlight> | addEventHandler ( "onResourceStart", getResourceRootElement(), logoutAll )</syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Account_functions}} | {{Account_functions}} | ||
[[en:logOut]] | |||
[[ru:logOut]] | |||
[[es:logOut]] | |||
[[zh-cn:logOut]] |
Latest revision as of 15:06, 12 April 2021
This function logs the given player out of his current account.
Syntax
bool logOut ( player thePlayer )
OOP Syntax Help! I don't understand this!
- Method: player:logOut(...)
Required Arguments
- thePlayer: The player to log out of his current account
Returns
Returns true if the player was successfully logged out, false or nil if it failed for some reason, ie. the player was never logged in.
Example
This example logs every player out of their account when the resource is (re)started. This would be handy for resources that show a login screen onClientResourceStart.
function logoutAll () local players = getElementsByType ( "player" ) -- Get every player for k, player in ipairs ( players ) do -- For every player do the following... account = getPlayerAccount ( player ) -- Get every player's account if ( not isGuestAccount ( account ) ) then -- For every player that's logged in.... logOut ( player ) -- Log them out. end end end -- Trigger it when the resource (re)starts addEventHandler ( "onResourceStart", getResourceRootElement(), logoutAll )
See Also
- addAccount
- copyAccountData
- getAccount
- getAccountData
- getAccountName
- getAccountPlayer
- getAccountSerial
- getAccounts
- getAccountsBySerial
- getAllAccountData
- getPlayerAccount
- isGuestAccount
- logIn
- logOut
- removeAccount
- setAccountData
- setAccountPassword
- getAccountByID
- getAccountID
- getAccountIP
- getAccountsByData
- getAccountsByIP
- setAccountName