Skip to content

Commit 865684a

Browse files
committed
Add convar to disable DMs
1 parent daf2441 commit 865684a

File tree

7 files changed

+26
-4
lines changed

7 files changed

+26
-4
lines changed

lua/autorun/sh_custom_chat.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ CreateConVar( "custom_chat_enable_absence_messages", "1", bit.bor( FCVAR_ARCHIVE
6767
CreateConVar( "custom_chat_enable_friend_messages", "1", bit.bor( FCVAR_ARCHIVE, FCVAR_REPLICATED, FCVAR_NOTIFY ),
6868
"Show messages to players when their friends spawn on the server.", 0, 1 )
6969

70+
CreateConVar( "custom_chat_enable_dms", "1", bit.bor( FCVAR_ARCHIVE, FCVAR_REPLICATED, FCVAR_NOTIFY ),
71+
"Allow players to chat with eachother privately.", 0, 1 )
72+
7073
function CustomChat.Print( str, ... )
7174
MsgC( Color( 0, 123, 255 ), "[Custom Chat] ", Color( 255, 255, 255 ), string.format( str, ... ), "\n" )
7275
end

lua/custom_chat/client/vgui/chat_frame.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ function PANEL:OpenChat()
169169

170170
self:SetActiveChannel( self.lastChannelId or "global" )
171171
end
172+
173+
if CustomChat.GetConVarInt( "enable_dms", 1 ) == 0 then
174+
for id, channel in pairs( self.channels ) do
175+
if channel.isDM then
176+
self:RemoveChannel( id )
177+
end
178+
end
179+
end
172180
end
173181

174182
function PANEL:CloseChat()
@@ -401,6 +409,12 @@ function PANEL:SubmitMessage()
401409
end
402410

403411
function PANEL:OpenDirectMessage()
412+
if CustomChat.GetConVarInt( "enable_dms", 1 ) == 0 then
413+
Derma_Message( L"server_dms_disabled", L"open_dm", L"ok" )
414+
415+
return
416+
end
417+
404418
local frame = vgui.Create( "DFrame" )
405419
frame:SetSize( 380, 300 )
406420
frame:SetTitle( L"channel.open_dm" )

lua/custom_chat/server/net_messages.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ net.Receive( "customchat.say", function( _, speaker )
4949
if util.SteamIDTo64( channel ) ~= "0" then
5050
dmTarget = player.GetBySteamID( channel )
5151
if not IsValid( dmTarget ) then return end
52+
if CustomChat.GetConVarInt( "enable_dms", 1 ) == 0 then return end
5253
end
5354

5455
text = CustomChat.CleanupString( text )

resource/localization/en/custom_chat.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,5 @@ custom_chat.time.days=days
151151
custom_chat.time.hours=hours
152152
custom_chat.time.minutes=minutes
153153
custom_chat.time.seconds=seconds
154-
custom_chat.last_seen2=ago.
154+
custom_chat.last_seen2=ago.
155+
custom_chat.server_dms_disabled=Direct messages are disabled on this server.

resource/localization/pt-br/custom_chat.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,5 @@ custom_chat.time.days=dias
151151
custom_chat.time.hours=horas
152152
custom_chat.time.minutes=minutos
153153
custom_chat.time.seconds=segundos
154-
custom_chat.last_seen2=atrás.
154+
custom_chat.last_seen2=atrás.
155+
custom_chat.server_dms_disabled=Conversas privadas estão desabilitadas neste servidor.

resource/localization/ru/custom_chat.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,5 @@ custom_chat.time.days=д.
151151
custom_chat.time.hours=ч.
152152
custom_chat.time.minutes=мин.
153153
custom_chat.time.seconds=сек.
154-
custom_chat.last_seen2=назад.
154+
custom_chat.last_seen2=назад.
155+
custom_chat.server_dms_disabled=На этом сервере отключены прямые сообщения.

resource/localization/tr/custom_chat.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,5 @@ custom_chat.time.days=günler
151151
custom_chat.time.hours=saat
152152
custom_chat.time.minutes=dakika
153153
custom_chat.time.seconds=saniye
154-
custom_chat.last_seen2=önce oynadı.
154+
custom_chat.last_seen2=önce oynadı.
155+
custom_chat.server_dms_disabled=Bu sunucuda Doğrudan Mesajlar devre dışı bırakıldı.

0 commit comments

Comments
 (0)