Garry's Mod Wiki

GM:CheckPassword

boolean, string GM:CheckPassword( string steamID64, string ipAddress, string svPassword, string clPassword, string name )

Description

Called when a non local player connects to allow the Lua system to check the password.

The default behaviour in the base gamemodes emulates what would normally happen. If sv_password is set and its value matches the password passed in by the client - then they are allowed to join. If it isn't set it lets them in too.

Arguments

1 string steamID64
The 64bit Steam ID of the joining player, use util.SteamIDFrom64 to convert it to a "STEAM_0:" one.
2 string ipAddress
The IP of the connecting client
3 string svPassword
The current value of sv_password (the password set by the server)
4 string clPassword
The password provided by the client
5 string name
The name of the joining player

Returns

1 boolean
If the hook returns false then the player is disconnected
2 string
If returning false in the first argument, then this should be the disconnect message. This will default to "#GameUI_ServerRejectBadPassword", which is "Bad Password." translated to the client's language.

Example

A user access whitelist to the server

Available pre-defined messages can be found in ../sourceengine/resource/gameui_english.txt files.

Suggested messages are #GameUI_ConnectionFailed and #GameUI_ServerRejectLANRestrict

local allowed = { ["76561198012345678"] = true, -- Me ["76561198123456789"] = true, -- Friend #1 ["76561198234567890"] = true, -- Friend #2 } hook.Add( "CheckPassword", "access_whitelist", function( steamID64 ) if not allowed[steamID64] then return false, "#GameUI_ServerRejectLANRestrict" end end )

Page Links


Special Pages


Wikis

?

Render Time: 66ms

Session 0
DB GetPage 5
Generate Html 28
SaveChanges 19
Render Body 0
Render Sidebar 12