• Print

Author Topic: Use "gag" with lua  (Read 4581 times)

0 Members and 1 Guest are viewing this topic.

Offline simpleee

  • Newbie
  • *
  • Posts: 13
  • Karma: 1
Use "gag" with lua
« on: December 21, 2013, 09:35:20 am »
How can i use the "gag" feature with lua?
« Last Edit: December 21, 2013, 09:37:11 am by simpleee »

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Use "gag" with lua
« Reply #1 on: December 21, 2013, 10:00:04 am »
We use the "PlayerCanHearPlayersVoice" hook to implement the gag.
Experiencing God's grace one day at a time.

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Use "gag" with lua
« Reply #2 on: December 21, 2013, 10:03:48 am »
Example of a PlayerCanHearPlayersVoice hook:
Code: Lua
  1.  
  2. local function GagPlayer( listener, talker )
  3.         if not talker:IsAdmin() then   
  4.                 return false
  5.         end    
  6. end
  7. hook.Add( "PlayerCanHearPlayersVoice", "gag_player", GagPlayer )
  8.  

This will make only players who are admins able to talk.

Beware, using too many of these hooks can cause server lag as they are very intensive.
« Last Edit: December 21, 2013, 10:06:29 am by Cobalt77 »

  • Print