Problem With Player Connect/Disconnect Hooks

My current script is:
[lua]function fPlayerDisconnect(ply)
for _, v in pairs(player.GetAll()) do
if v:IsAdmin then
v:ChatPrint(ply:Nick() … " has disconnected. [" … ply:SteamID() … “] | [” … ply:IPAddress() … “]”)
else
v:ChatPrint(ply:Nick() … " has disconnected. [" … ply:SteamID() … “]”)
end
end
end
hook.Add(“PlayerDisconnected”, “disconnect”, fPlayerDisconnect)
function playerConnect(name, address, steamid)
for _, v in pairs(player.GetAll()) do
if v:IsAdmin() then
v:ChatPrint(name … "'s Steam ID is " … steamid … ", and their IP address is " … address … “.”)
else
v:ChatPrint(name … "'s Steam ID is " … steamid … “.”)
end
end
end
hook.Add(“PlayerConnect”, “connect”, playerConnect)[/lua]

I have that in autorun/server, but nothing happens. What’s wrong with it?

At line 3 in your code it has v:IsAdmin and you forgot the brackets. Change it to v:IsAdmin()
In PlayerConnect steamid is not valid as PlayerConnect only has name and ip (thus you can’t print their steamid unless you did it in playerinitialspawn or otherwise).

PlayerDisconnected is bugged anyway… it sometimes gets called and sometimes not.

Use [http://wiki.garrysmod.com/images/9/9f/NewerServer.png

PlayerInitialSpawn](http://wiki.garrysmod.com/?title=Gamemode.PlayerInitialSpawn)
then chatprint to all whatever you wanted, and for their SteamID do the [http://wiki.garrysmod.com/images/0/0d/NewerShared.png

SteamID](http://wiki.garrysmod.com/?title=Player.SteamID) function (instead of playerconnect). You can use a module for IP.

[http://wiki.garrysmod.com/images/9/9f/NewerServer.png

PlayerDisconnected](http://wiki.garrysmod.com/?title=Gamemode.PlayerDisconnected) works fine for me and never screws up. You are messing something up, maybe because you typed “PlayerDisconnect” instead of “PlayerDisconnected” (you said in your last comment you did playerdisconnect).

I used PlayerDisconnected I just missspelled it here…