• Print

Author Topic: Dead Mute  (Read 5704 times)

0 Members and 1 Guest are viewing this topic.

Offline soccercrazy195

  • Newbie
  • *
  • Posts: 9
  • Karma: 0
Dead Mute
« on: January 28, 2010, 06:00:36 pm »
Can we please have an automute(Players get muted when they die) mod?

Offline vader0146

  • Jr. Member
  • **
  • Posts: 63
  • Karma: 9
Re: Dead Mute
« Reply #1 on: February 09, 2010, 06:43:27 am »
hook.Add("PlayerSay", "MuteWhenDead", function( ply )
   if !ply:Alive() then
      return false
   end
end )

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Dead Mute
« Reply #2 on: February 09, 2010, 03:50:17 pm »
PlayerSay is a tricky hook.
So many scripts rely on it, but returning anything breaks the PlayerSay hook for all other scripts (if I remember correctly).
Including ULX chat commands.

Using a clientside Gamemode.OnPlayerChat would probably be better for not breaking an entire server hook system.
« Last Edit: February 09, 2010, 03:53:34 pm by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Dead Mute
« Reply #3 on: February 09, 2010, 03:54:13 pm »
hook.Add("PlayerSay", "MuteWhenDead", function( ply )
   if !ply:Alive() then
      return false
   end
end )

In order to not break other hooks, here's a better implementation:
Code: Lua
  1. hook.Add("PlayerSay", "MuteWhenDead", function( ply )
  2.    if !ply:Alive() then
  3.       return false
  4.    end
  5. end, 19 )

This uses ULib's modified hook.Add to do priorities, which means that all other mods get a shot at doing things with the text before it's blocked outright.
Experiencing God's grace one day at a time.

  • Print