ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. setServerPassword

Function

setServerPassword

ServerServerIdentical to MTA:SA

Sets or removes the server password at runtime. The server immediately requires the password from new players; the launcher gets the new password with the next server list report (up to 30 seconds) - until then entering the new password may fail. Players already on the server are not kicked. nil/false removes the password.

Syntax

bool setServerPassword([string password = nil])

Arguments

passwordstring, optional = nil
The new password, or nil/false.

Returns

true on success.

Example

addCommandHandler("zamknij", function(player, _, pass)
    if hasObjectPermissionTo(player, "function.setServerPassword") then
        setServerPassword(pass)
        outputChatBox(pass and "Serwer zamkniety haslem" or "Serwer otwarty", player)
    end
end)

Notes

The change lasts until the server restarts; set a permanent password in server-config.json.

See also