• How to show steamIDs on Connect and Disconnect?
    5 replies, posted
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. [url]http://wiki.garrysmod.com/?title=Gamemode_Hooks[/url]
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]
[QUOTE=Grea$eMonkey;28626619]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][/QUOTE] PlayerDisconnected is still not reliable...
[QUOTE=Wizard of Ass;28626695]PlayerDisconnected is still not reliable...[/QUOTE] 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]
Sorry, you need to Log In to post a reply to this thread.