Skip to content

Commit 54281ca

Browse files
committed
Add convar to toggle join/leave steamids, default is 0
1 parent de9fa77 commit 54281ca

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

lua/autorun/sh_custom_chat.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ CreateConVar( "custom_chat_enable_friend_messages", "1", bit.bor( FCVAR_ARCHIVE,
7373
CreateConVar( "custom_chat_enable_dms", "1", bit.bor( FCVAR_ARCHIVE, FCVAR_REPLICATED, FCVAR_NOTIFY ),
7474
"Allow players to chat with eachother privately.", 0, 1 )
7575

76+
CreateConVar( "custom_chat_show_steamid_on_join_leave", "0", bit.bor( FCVAR_ARCHIVE, FCVAR_REPLICATED, FCVAR_NOTIFY ),
77+
"Should the SteamID be visible when showing join/leave messages?", 0, 1 )
78+
7679
function CustomChat.Print( str, ... )
7780
MsgC( Color( 0, 123, 255 ), "[Custom Chat] ", Color( 255, 255, 255 ), string.format( str, ... ), "\n" )
7881
end

lua/custom_chat/client/join_leave.lua

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,18 @@ hook.Add( "player_connect_client", "CustomChat.ShowConnectMessages", function( d
4141
}
4242
end
4343

44-
chat.AddText(
44+
local parts = {
4545
Color( 255, 255, 255 ), JoinLeave.joinPrefix,
46-
Color( c[1], c[2], c[3] ), name,
47-
Color( 150, 150, 150 ), " <" .. steamId .. "> ",
46+
Color( c[1], c[2], c[3] ), name, " ",
4847
Color( 255, 255, 255 ), JoinLeave.joinSuffix
49-
)
48+
}
49+
50+
if CustomChat.GetConVarInt( "show_steamid_on_join_leave", 0 ) > 0 then
51+
table.insert( parts, 5, Color( 150, 150, 150 ) )
52+
table.insert( parts, 5, " <" .. steamId .. ">" )
53+
end
54+
55+
chat.AddText( unpack( parts ) )
5056
end, HOOK_LOW )
5157

5258
hook.Add( "player_disconnect", "CustomChat.ShowDisconnectMessages", function( data )
@@ -72,13 +78,19 @@ hook.Add( "player_disconnect", "CustomChat.ShowDisconnectMessages", function( da
7278
}
7379
end
7480

75-
chat.AddText(
81+
local parts = {
7682
Color( 255, 255, 255 ), JoinLeave.leavePrefix,
77-
Color( c[1], c[2], c[3] ), name,
78-
Color( 150, 150, 150 ), " <" .. steamId .. "> ",
83+
Color( c[1], c[2], c[3] ), name, " ",
7984
Color( 255, 255, 255 ), JoinLeave.leaveSuffix,
8085
Color( 150, 150, 150 ), " (" .. data.reason .. ")"
81-
)
86+
}
87+
88+
if CustomChat.GetConVarInt( "show_steamid_on_join_leave", 0 ) > 0 then
89+
table.insert( parts, 5, Color( 150, 150, 150 ) )
90+
table.insert( parts, 5, " <" .. steamId .. ">" )
91+
end
92+
93+
chat.AddText( unpack( parts ) )
8294
end, HOOK_LOW )
8395

8496
local function OnPlayerActivated( ply, steamId, name, color, absenceLength )

0 commit comments

Comments
 (0)