• Show SteamIDs in console
    18 replies, posted
My Super Admins, Admins, and mods have been requesting that I make it so they also can see the SteamID's of people diconnecting in console incase people RDM and leave and stuff. I was wonder where do I edit it so they can see it because so far I am the only one that can.
[code] function histeamid( ply ) print(ply:SteamID()) -- Change the above print to whatever way you want it to display the steam id. end hook.Add( "PlayerDisconnected", "getsteamid", histeamid ) [/code] Look next time. [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5741-2.html"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5741-2.html[/URL] [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index01a8.html"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index01a8.html[/URL] EDIT: Go to server files, put this code in the above file: /garrysmod/lua/autorun/server/steamidgrab.lua
you probably already know this if you need a way to see current players set a common bind to "Status" bind X "Status
[QUOTE=sackcreator54;42437170][code] function histeamid( ply ) print(ply:SteamID()) -- Change the above print to whatever way you want it to display the steam id. end hook.Add( "PlayerDisconnected", "getsteamid", histeamid ) [/code] Look next time. [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5741-2.html"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5741-2.html[/URL] [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index01a8.html"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index01a8.html[/URL] EDIT: Go to server files, put this code in the above file: /garrysmod/lua/autorun/server/steamidgrab.lua[/QUOTE] This only works if you give every single admin access to your server's main console
[QUOTE=sackcreator54;42437170][code] function histeamid( ply ) print(ply:SteamID()) -- Change the above print to whatever way you want it to display the steam id. end hook.Add( "PlayerDisconnected", "getsteamid", histeamid ) [/code] Look next time. [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5741-2.html"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5741-2.html[/URL] [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index01a8.html"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index01a8.html[/URL] EDIT: Go to server files, put this code in the above file: /garrysmod/lua/autorun/server/steamidgrab.lua[/QUOTE] Localize your shit. [code] local function stuff( ply ) PrintMessage( HUD_PRINTCONSOLE, string.format( "%s (%s) has left the game", ply:Nick(), ply:SteamID() ) end hook.Add( "PlayerDisconnected", "stuff", stuff ) [/code]
If you only want admins to see the printouts: [code] hook.Add("PlayerDisconnected", "AdminNotify", function(ply) for k,v in pairs(player.GetAll()) do if v:IsAdmin() then v:SendLua([[print("Player: ]]..ply:Name()..[[ has disconnected! (]]..ply:SteamID()..[[)")]]) end end end) [/code]
[QUOTE=lordofdafood;42442448]If you only want admins to see the printouts: [code] hook.Add("PlayerDisconnected", "AdminNotify", function(ply) for k,v in pairs(player.GetAll()) do if v:IsAdmin() then v:SendLua([[print("Player: ]]..ply:Name()..[[ has disconnected! (]]..ply:SteamID()..[[)")]]) end end end) [/code][/QUOTE] Never use SendLua, that's a terrible thing to do. Especially when there are literally functions (such as you know, [I]PrintMessage[/I]) that do exactly what you just wrote.
you guys are being so lazy holy hell [lua]--[[ Yay for stupid people not knowing how to make a simple connect/disconnect message! Zero the fallen etc etc pls ty ]]-- if (SERVER) then print("Compact/Shared D/Connect Print Starting!") util.AddNetworkString("dcchatprint") local chat = {} local dcprint = {} function chat.print(p, t) net.Start("dcchatprint") net.WriteTable(t) net.Send(p) end function dcprint.getTable(p, c) return ( { Color(0, 0, 0), "[", Color(0,0,255), "SnoopDoge", -- CHANGE YOUR SERVER NAME HERE TY Color(0,0,0), "]", Color(3, 242, 33), p:Name(), Color(255, 0, 0), " has ",(!c && "dis" || ""), "connected!", Color(0,0,0), "[", Color(255,0,0), p:SteamID(), Color(0,0,0), "]" } ) end local function cprintf(con) return ( function(p) return dcprint.getTable(p, con) end ) end hook.Add( "PlayerAuthed", "cnect_print", function(p) chat.print(player.GetAll(), cprintf(true)(p)) end ) hook.Add( "PlayerDisconnected", "dnect_print", function(p) chat.print(player.GetAll(), cprintf(false)(p)) end ) end if (CLIENT) then net.Receive( "dcchatprint", function() local t = net.ReadTable() chat.AddText(unpack(t)) end ) end[/lua]
Oh god the terrible line spacing.
[QUOTE=zerothefallen;42445997]-snip-[/QUOTE] I'm not sure if you're trolling, or if you don't know anything about indenting. [IMG]http://i259.photobucket.com/albums/hh288/krispos42/Animated/spongebob_my_eyes.gif[/IMG]
[QUOTE=OzymandiasJ;42446099]Oh god the terrible line spacing.[/QUOTE] extremely old stuff and i didnt know how to release the enter key there ya go, i prefer having the table that way thou
[QUOTE=zerothefallen;42446360]extremely old stuff and i didnt know how to release the enter key there ya go, i prefer having the table that way thou[/QUOTE] If you're going to act like an arrogant ass, maybe you should make sure your code isn't terrible first huh?
Tension, tension everywhere. [lua] function PlayerDisconnect( ply ) PrintMessage( HUD_PRINTTALK, ply:Nick().. " has disconnected, their SteamID is: " ..ply:SteamID() ) end hook.Add( "PlayerDisconnected", "playerDisconnected", PlayerDisconnect ) [/lua] Put it in /lua/autorun/server. Prints their name and steamid to chat when they disconnect.
[QUOTE=Th3applek1d;42447077]Tension, tension everywhere. [lua] function PlayerDisconnect( ply ) PrintMessage( HUD_PRINTTALK, ply:Nick().. " has disconnected, their SteamID is: " ..ply:SteamID() ) end hook.Add( "PlayerDisconnected", "playerDisconnected", PlayerDisconnect ) [/lua] Put it in /lua/autorun/server. Prints their name and steamid to chat when they disconnect.[/QUOTE] [QUOTE=EvacX;42442212]Localize your shit.[/QUOTE]
If you want it to print in the chat and console: [lua] if SERVER then AddCSLuaFile() util.AddNetworkString("chat_AddText") chat = chat or {} function chat.AddText(...) net.Start("chat_AddText") net.WriteTable({...}) net.Broadcast() end hook.Add("PlayerAuthed", "chat.PlayerAuthed", function(ply) chat.AddText(color_white, "[SV] ", Color(150,150,0), ply:Nick(), " has connected to the server!") end) hook.Add("PlayerDisconnected", "chat.PlayerDisconnected", function(ply) chat.AddText(color_white, "[SV] ", Color(150,150,0), ply:Nick(), color_white, " (", ply:SteamID(), ") ", Color(150,150,0), "has disconnected from the server!") end) else net.Receive("chat_AddText", function(len) chat.AddText(unpack(net.ReadTable())) end) end [/lua] If you want it to print in just the console: [lua] if SERVER then hook.Add("PlayerDisconnected", "chat.PlayerDisconnected", function(ply) for k,v in ipairs(player.GetAll()) do if !v:IsAdmin() then continue end v:PrintMessage(HUD_PRINTCONSOLE, ply:Nick().." ("..(ply:SteamID())..") has disconnected from the server!") end end) end [/lua]
[QUOTE=EvacX;42446967]If you're going to act like an arrogant ass, maybe you should make sure your code isn't terrible first huh?[/QUOTE] It does what it's suppose to. Stop crying kid.
Isn't it as simple as this? [LUA] local function ShowSteamID( _p ) for i,v in pairs( player.GetAll() ) do if ( v:IsAdmin() ) then v:PrintMessage( HUD_PRINTCONSOLE, _p:Nick() .. " disconnected, Steam ID: " .. _p:SteamID() .. "\n" ); end end end hook.Add( "PlayerDisconnected", "ShowSteamID", ShowSteamID ); [/LUA]
This may be a stupid question, but... I've never understood what localizing a function does. Can someone tell me what it does? I know what localizing variables does, but not functions. Rate me dem boxooes
[QUOTE=http://www.lua.org/pil/6.2.html]a function that is restricted to a given scope.[/QUOTE] You can read more about local Lua functions [URL="http://www.lua.org/pil/6.2.html"]here[/URL].
Sorry, you need to Log In to post a reply to this thread.