Author Topic: all messages are in the chat  (Read 296 times)

0 Members and 1 Guest are viewing this topic.

Offline Chrinis

  • Newbie
  • *
  • Posts: 3
  • Karma: -1
all messages are in the chat
« on: November 10, 2018, 08:16:26 AM »
how to disable that all messages are in the chat?

Player Majin left the game (Disconnect by user.)
Player Majin has joined the game

Offline Timmy

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 185
  • Karma: 149
  • Code monkey
    • ULX Unofficial Documentation
Re: all messages are in the chat
« Reply #1 on: November 11, 2018, 12:05:29 PM »
Certain types of messages can be filtered using the ChatText hook. The example below suppresses the default join/leave messages.

Code: [Select]
-- client-side
hook.Add( "ChatText", "HideJoinLeave", function( index, name, text, type )
  if type == "joinleave" then
    return true
  end
end )

Offline Chrinis

  • Newbie
  • *
  • Posts: 3
  • Karma: -1
Re: all messages are in the chat
« Reply #2 on: November 17, 2018, 03:35:11 AM »
Where should i write this in?

Offline Timmy

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 185
  • Karma: 149
  • Code monkey
    • ULX Unofficial Documentation
Re: all messages are in the chat
« Reply #3 on: November 17, 2018, 01:03:07 PM »
Any client-side Lua file will do.

For example: (garrysmod)/lua/autorun/client/hidejoinleave.lua

Servers will automatically send files inside (garrysmod)/lua/autorun/client to clients, and clients will automatically run them.

Offline Chrinis

  • Newbie
  • *
  • Posts: 3
  • Karma: -1
Re: all messages are in the chat
« Reply #4 on: November 26, 2018, 08:34:13 AM »
And Karma bans aren’t in the chat so no one know that the user was banned

Offline Timmy

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 185
  • Karma: 149
  • Code monkey
    • ULX Unofficial Documentation
Re: all messages are in the chat
« Reply #5 on: November 26, 2018, 11:08:11 AM »
Seems like TTT does not provide this kind of feedback to other players.

It only takes a couple of lines to add this. I have added an example below.

Code: [Select]
-- server-side
hook.Add( "PlayerDisconnected", "KarmaBanNotification", function( ply )
    if ply.karma_kicked then
        PrintMessage( HUD_PRINTTALK, "[SERVER] Karma banned " .. ply:Nick() )
    end
end )