Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Player mute
#1
Is it possible to have any type of player mute for a server? (!mute XXX)

Reply

#2
(02-01-2012, 19:41)kraze1994 Wrote: Is it possible to have any type of player mute for a server? (!mute XXX)
What do you mean with mute? Chat or voice chat?

Both would be possible for an admin plugin.
[Image: azuw.jpg]
Reply

#3
I would love to see both with different commands to be honest, but I would prefer voice over anything.
Reply

#4
Voice probably wouldn't be possible, chat would be possible for sure
Reply

#5
I will code a mute plugin for chat somewhere tomorrow
Reply

#6
I already made one but its in the itsmodders section, Didn't test it thats why its not public

edit: Source
CSHARP Code
  1. using System;
  2. using Addon;
  3.  
  4. namespace MW3_TextChatMute
  5. {
  6. public class TextChatMute : CPlugin
  7. {
  8. System.Collections.Generic.List<Player> MuteDb = new System.Collections.Generic.List<Player>();
  9. System.Timers.Timer Timer = new System.Timers.Timer();
  10.  
  11. // Start the timer and show the server owner that the plugin is loaded
  12. public override void OnServerLoad()
  13. {
  14. Timer.Interval = 10000;
  15. Timer.Elapsed += new System.Timers.ElapsedEventHandler( Timer_Elapsed );
  16. Timer.Enabled = true;
  17. Timer.Start();
  18.  
  19. ServerLog( LogType.LogData, "TextChatMute v1 loaded" );
  20. ServerPrint( "TextChatMute v1 loaded" );
  21. }
  22.  
  23. // Check every 10 seconds if the player is still ingame, if not then delete him from the database
  24. void Timer_Elapsed( object sender, System.Timers.ElapsedEventArgs e )
  25. {
  26. foreach ( Player player in MuteDb )
  27. if ( !IsStillIngame( player.Client ) )
  28. DeletePlayer( player );
  29. }
  30.  
  31. // Fix for removing players because I cannot delete them in a foreach loop o_O
  32. void DeletePlayer( Player player )
  33. {
  34. MuteDb.Remove( player );
  35. ServerLog( LogType.LogData, "DEBUG: Removed mutelist for: " + player.Client.Name );
  36. player.Client = null;
  37. player.Muted = null;
  38. player = null;
  39. }
  40.  
  41. // Check if the player is still ingame
  42. bool IsStillIngame( ServerClient client )
  43. {
  44. foreach ( ServerClient player in GetClients() )
  45. if ( client == player )
  46. return true;
  47.  
  48. return false;
  49. }
  50.  
  51. // Add the player to the mute database
  52. public override void OnPlayerConnect( ServerClient Client )
  53. {
  54. MuteDb.Add( new Player( Client ) );
  55. ServerLog( LogType.LogData, "DEBUG: Added mutelist for: " + Client.Name );
  56. }
  57.  
  58.  
  59. public override ChatType OnSay( string Message, ServerClient Client )
  60. {
  61. // Mute a player
  62. if ( Message.StartsWith( "!mute" ) )
  63. {
  64. if ( Message.Length <= 6 )
  65. TellClient( Client.ClientNum, "^3Usage: !mute [Playername]", true );
  66. else if ( GetClientByName( Message.Substring( 6 ) ) != null )
  67. GetPlayerMute( Client ).AddMute( GetClientByName( Message.Substring( 6 ) ) );
  68. else
  69. TellClient( Client.ClientNum, "^3There was no player found!", true );
  70. return ChatType.ChatContinue;
  71. }
  72. // Unmute a player
  73. else if ( Message.StartsWith( "!unmute" ) )
  74. {
  75. if ( Message.Length <= 6 )
  76. TellClient( Client.ClientNum, "^3Usage: !unmute [Playername]", true );
  77. else if ( GetClientByName( Message.Substring( 6 ) ) != null )
  78. GetPlayerMute( Client ).RemoveMute( GetClientByName( Message.Substring( 6 ) ) );
  79. else
  80. TellClient( Client.ClientNum, "^3There was no player found!", true );
  81. return ChatType.ChatContinue;
  82. }
  83. // Show muted players
  84. else if ( Message.StartsWith( "!mutelist" ) )
  85. {
  86. string s = "^3Muted: ";
  87. foreach ( Player player in MuteDb )
  88. if ( player.Client == Client )
  89. foreach ( ServerClient client in player.Muted )
  90. s += client.Name + ", ";
  91. TellClient( Client.ClientNum, s, true );
  92. return ChatType.ChatContinue;
  93. }
  94.  
  95. // Show the text to everyone that didn't mute this Client
  96. foreach ( Player player in MuteDb )
  97. if ( !player.IsMuted( Client ) )
  98. TellClient( player.Client.ClientNum, Message, true );
  99.  
  100. return ChatType.ChatContinue;
  101. }
  102.  
  103. // Get the 'Player' class for this client
  104. Player GetPlayerMute( ServerClient client )
  105. {
  106. foreach ( Player player in MuteDb )
  107. if ( player.Client == client )
  108. return player;
  109. return null;
  110. }
  111.  
  112. // Get the 'ServerClient' for this player(name)
  113. ServerClient GetClientByName( string name )
  114. {
  115. foreach ( ServerClient client in GetClients() )
  116. if ( client.Name.StartsWith( name, StringComparison.InvariantCultureIgnoreCase )
  117. || client.Name.EndsWith( name, StringComparison.InvariantCultureIgnoreCase ) )
  118. return client;
  119. return null;
  120. }
  121. }
  122.  
  123. public class Player
  124. {
  125. public ServerClient Client;
  126. public System.Collections.Generic.List<ServerClient> Muted = new System.Collections.Generic.List<ServerClient>();
  127. public Player( ServerClient client ) { Client = client; }
  128. public bool IsMuted( ServerClient client ) { return Muted.Contains( client ); }
  129. public void AddMute( ServerClient client ) { Muted.Add( client ); }
  130. public void RemoveMute( ServerClient client ) { Muted.Remove( client ); }
  131. }
  132. }
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#7
Ah nice, won't code one tomorrow then Tongue
-Bonemind
Reply

#8
(02-02-2012, 00:06)bonemind Wrote: Ah nice, won't code one tomorrow then Tongue
-Bonemind

Can you compile, test and debug it for me since I can't do this? Smile
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#9
(02-02-2012, 00:11)iAegle Wrote:
(02-02-2012, 00:06)bonemind Wrote: Ah nice, won't code one tomorrow then Tongue
-Bonemind

Can you compile, test and debug it for me since I can't do this? Smile

Will do that tomorrow, atm i'm not a great bugtester/coder/anything elseTongue
I'll post my results here ASAP though
Reply

#10
Ive compiled and tested

Bugs:
I tried unmuting my self and does not work crashed my server
!mutelist and !mute work


only thing i havent tested is muting and unmuting another person

You may test if u like.


Attached Files
.rar   MW3_TextChatMute.rar (Size: 3.06 KB / Downloads: 13)
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Help Sentry Gun kill = Player kill Snake 8 5,859 11-07-2013, 13:41
Last Post: Nekochan
  Player can write Fl0w_.JACKDAN 2 3,347 09-19-2013, 16:36
Last Post: Fl0w_.JACKDAN
  [CoD 4] Trying to set a player -- DidUknowiPwn 7 5,844 07-03-2013, 21:58
Last Post: Pozzuh
  [Release] Black Ops Single Player/Zombie Trainer V3.6 Craig87 52 88,507 07-01-2013, 15:12
Last Post: explosivebanana55
Video Preview AIZombies eXtreme 2.0 / Zombie Player (Music Player) DidUknowiPwn 4 5,862 06-24-2013, 16:37
Last Post: DidUknowiPwn
  "VEH_LinkCommonChecks: Player already has an owner" - After long games akillj 4 3,585 06-07-2013, 11:38
Last Post: akillj
  Question on how to "Spawn" a flying rocket as a player? akillj 8 5,539 06-04-2013, 01:54
Last Post: rotceh_dnih
  Using Cheat Engine with Zombies Single Player kikkawa 3 10,900 06-03-2013, 01:18
Last Post: kikkawa
  [Request] Random player model hillbilly 1 2,743 05-12-2013, 08:30
Last Post: archit
Brick [Release] MW3 Single Player CONSOLE v1.9.433 can1907 13 29,428 05-01-2013, 15:18
Last Post: vton

Forum Jump:


Users browsing this thread:
2 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.