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 [url="http://wiki.garrysmod.com/?title=Gamemode.PlayerConnect"]PlayerConnect[/url] 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.
[QUOTE=Wizard of Ass;24785483]PlayerDisconnect is bugged anyway... it sometimes gets called and sometimes not.[/QUOTE]
Use [url="http://wiki.garrysmod.com/?title=Gamemode.PlayerInitialSpawn"][img]http://wiki.garrysmod.com/images/9/9f/NewerServer.png[/img] PlayerInitialSpawn[/url]
then chatprint to all whatever you wanted, and for their SteamID do the [url="http://wiki.garrysmod.com/?title=Player.SteamID"] [img]http://wiki.garrysmod.com/images/0/0d/NewerShared.png[/img] SteamID[/url] function (instead of playerconnect). You can use a module for IP.
[url="http://wiki.garrysmod.com/?title=Gamemode.PlayerDisconnected"][img]http://wiki.garrysmod.com/images/9/9f/NewerServer.png[/img] PlayerDisconnected[/url] 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...
Sorry, you need to Log In to post a reply to this thread.