GetServerPassword: Difference between revisions
Jump to navigation
Jump to search
(New page: __NOTOC__ {{Server function}}<!-- Change this to "Client function" or "Server function" appropriately--> <!-- Describe in plain english what this function does. Don't go into details, jus...) |
No edit summary |
||
Line 15: | Line 15: | ||
==Example== | ==Example== | ||
This example prints the serverpassword to the player | |||
This example | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | 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 != nil) then | |||
outputChatBox ( "The server password is " .. getServerPassword (), thePlayer ) | |||
-- Else print that there isnt any password | |||
else | |||
outputChatBox ( "The server password is " .. getServerPassword (), thePlayer ) | |||
end | |||
end | |||
-- Add console command 'viewpassword' | |||
addCommandHandler ( "viewpassword", viewPassword ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Server functions}} | {{Server functions}} | ||
Revision as of 12:04, 5 January 2008
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 != nil) then outputChatBox ( "The server password is " .. getServerPassword (), thePlayer ) -- Else print that there isnt any password else outputChatBox ( "The server password is " .. getServerPassword (), thePlayer ) end end -- Add console command 'viewpassword' addCommandHandler ( "viewpassword", viewPassword )
See Also
- getMaxPlayers
- getServerConfigSetting
- getServerHttpPort
- getServerName
- getServerPassword
- getServerPort
- isGlitchEnabled
- setGlitchEnabled
- setMaxPlayers
- setServerConfigSetting
- setServerPassword
- shutdown