GetServerPassword: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
| (3 intermediate revisions by 3 users not shown) | |||
| Line 23: | Line 23: | ||
-- Check if the server has a password | -- Check if the server has a password | ||
-- If the server has an password, echo it | -- If the server has an password, echo it | ||
if | if password then | ||
outputChatBox ( "The server password is " .. | outputChatBox ( "The server password is " .. password, thePlayer ) | ||
-- Else print that there isnt any password | -- Else print that there isnt any password | ||
Latest revision as of 14:46, 16 December 2014
This function returns the current password required to join the server.
Syntax
string getServerPassword ()
Returns
Returns the current server password as a string if it has a password, if not it returns nil.
Example
This example prints the serverpassword to the player
function viewPassword ( thePlayer, command )
-- Put the password in a var
local password = getServerPassword ()
-- Check if the server has a password
-- If the server has an password, echo it
if password then
outputChatBox ( "The server password is " .. password, thePlayer )
-- Else print that there isnt any password
else
outputChatBox ( "The server doesn't have any password set", thePlayer )
end
end
-- Add console command 'viewpassword'
addCommandHandler ( "viewpassword", viewPassword )
See Also
- getMaxPlayers
- getServerConfigSetting
- getServerHttpPort
- getServerName
- getServerPassword
- getServerPort
- isGlitchEnabled
- setGlitchEnabled
- setMaxPlayers
- setServerConfigSetting
- setServerPassword
- shutdown