CheckPassword Hook

Is there any possible way to return a custom message when a player gets kicked?

Yes, the second return value is exactly for that, just check the wiki.

Ah, Thanks a lot.

[editline]25th February 2014[/editline]

While we’re on it, why does this not work? The steam ID is correct.



hook.Add("CheckPassword", "Denied", function(SteamID, IP, ServerPass, UserPass, PlayerName) 
	return SteamID == "STEAM_0:0:19254119" 
end)


The only way i can get it to work is by doing:



hook.Add("CheckPassword", "Denied", function(SteamID, IP, ServerPass, UserPass, PlayerName) 
	return PlayerName == "SkitZz" 
end)


You are using a 32 bit steamid
32bit: STEAM_X:Y:Z
64bit: 76561197960287930

“string steamID
The 64bit Steam ID of the joining player”

Ah, thanks for the help.

Well, I’ve been trying to do so it just reads the steam id’s from a file, but I’ve not to join without getting the custom kick message. Here’s my code:




 

local function CreateConfig()

	local authfile = "76561197998773966"
	file.Write("authorizedusers.txt", authfile)
end

local function ReadAuthed()
file.Read( "authorizedusers.txt", "DATA" ) 

end

if !file.Exists("authorizedusers.txt", "DATA")
then
CreateConfig()
end


hook.Add("CheckPassword", "Keepout", function(SteamID, IP, ServerPass, UserPass, PlayerName) 
return SteamID == ReadAuthed(), "Access Denied" 


 



You might want to learn lua instead of just c+ping code you don’t understand…

Well, i just want to know why this does not work, because it prints the correct steam id to the server console.

Well then, you might want to post ALL the code not just a snippet; also you might want to not do file.Write (just change it without changing the lua file) and just create a function that does this ->
for _,stmd in pairs string/Explode(filecontents, ’
') do
if stmd == func_stmd then return troo end
end

and call that to get if the player is allowed on the server

It is all of the code, genius.

Alright, you read a file under ReadAuthed yet you don’t return the value so it’s impossible to see what is what… add a return to the file.Read