How to show steamIDs on Connect and Disconnect?

How do you make it show peoples steamid’s when they connect and disconnect? Show it in the chat.

Connect:
[lua]
function GM:PlayerConnect( player )
print( "Player " … player … " has joined with the SteamID " …player:SteamID())
end
[/lua]

Should work, wrote it fast.

And, you should search before.

And post in the questions subforum next time.

[editline]15th March 2011[/editline]

[lua]
hook.Add(“PlayerConnect”, “mycoolconnecthook”, function(ply)
print( "Player " … ply:Nick() … " has joined with the SteamID " … ply:SteamID())
end)
hook.Add(“PlayerDisconnected”, “mycooldisconnecthook”, function(ply)
print( "Player " … ply:Nick() … " has disconnected with the SteamID " … ply:SteamID())
end)
[/lua]

PlayerDisconnected is still not reliable…

I didn’t know it stopped being reliable. As an alternative you could use EntityRemoved and add an if ent:IsPlayer() statement to it. Never tried it, but it should work.

Add to lua/autorun/server

[lua]
function FirstSpawn( ply )
PrintMessage( HUD_PRINTTALK, ply:Nick()… " entered the server, their SteamID is: " …ply:SteamID() )
end

hook.Add( “PlayerInitialSpawn”, “playerInitialSpawn”, FirstSpawn )

function PlayerDisconnect( ply )
PrintMessage( HUD_PRINTTALK, ply:Nick()… " has disconnected, their SteamID is: " …ply:SteamID() )
end

hook.Add( “PlayerDisconnected”, “playerDisconnected”, PlayerDisconnect )
[/lua]