02-01-2012, 19:41
Is it possible to have any type of player mute for a server? (!mute XXX)
|
Player mute
|
|
02-01-2012, 19:41
Is it possible to have any type of player mute for a server? (!mute XXX)
02-01-2012, 20:23
(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.
02-01-2012, 20:41
I would love to see both with different commands to be honest, but I would prefer voice over anything.
02-01-2012, 20:46
Voice probably wouldn't be possible, chat would be possible for sure
02-01-2012, 23:38
I will code a mute plugin for chat somewhere tomorrow
I already made one but its in the itsmodders section, Didn't test it thats why its not public
edit: Source Code: using System;
using Addon;
namespace MW3_TextChatMute
{
public class TextChatMute : CPlugin
{
System.Collections.Generic.List<Player> MuteDb = new System.Collections.Generic.List<Player>();
System.Timers.Timer Timer = new System.Timers.Timer();
// Start the timer and show the server owner that the plugin is loaded
public override void OnServerLoad()
{
Timer.Interval = 10000;
Timer.Elapsed += new System.Timers.ElapsedEventHandler( Timer_Elapsed );
Timer.Enabled = true;
Timer.Start();
ServerLog( LogType.LogData, "TextChatMute v1 loaded" );
ServerPrint( "TextChatMute v1 loaded" );
}
// Check every 10 seconds if the player is still ingame, if not then delete him from the database
void Timer_Elapsed( object sender, System.Timers.ElapsedEventArgs e )
{
foreach ( Player player in MuteDb )
if ( !IsStillIngame( player.Client ) )
DeletePlayer( player );
}
// Fix for removing players because I cannot delete them in a foreach loop o_O
void DeletePlayer( Player player )
{
MuteDb.Remove( player );
ServerLog( LogType.LogData, "DEBUG: Removed mutelist for: " + player.Client.Name );
player.Client = null;
player.Muted = null;
player = null;
}
// Check if the player is still ingame
bool IsStillIngame( ServerClient client )
{
foreach ( ServerClient player in GetClients() )
if ( client == player )
return true;
return false;
}
// Add the player to the mute database
public override void OnPlayerConnect( ServerClient Client )
{
MuteDb.Add( new Player( Client ) );
ServerLog( LogType.LogData, "DEBUG: Added mutelist for: " + Client.Name );
}
public override ChatType OnSay( string Message, ServerClient Client )
{
// Mute a player
if ( Message.StartsWith( "!mute" ) )
{
if ( Message.Length <= 6 )
TellClient( Client.ClientNum, "^3Usage: !mute [Playername]", true );
else if ( GetClientByName( Message.Substring( 6 ) ) != null )
GetPlayerMute( Client ).AddMute( GetClientByName( Message.Substring( 6 ) ) );
else
TellClient( Client.ClientNum, "^3There was no player found!", true );
return ChatType.ChatContinue;
}
// Unmute a player
else if ( Message.StartsWith( "!unmute" ) )
{
if ( Message.Length <= 6 )
TellClient( Client.ClientNum, "^3Usage: !unmute [Playername]", true );
else if ( GetClientByName( Message.Substring( 6 ) ) != null )
GetPlayerMute( Client ).RemoveMute( GetClientByName( Message.Substring( 6 ) ) );
else
TellClient( Client.ClientNum, "^3There was no player found!", true );
return ChatType.ChatContinue;
}
// Show muted players
else if ( Message.StartsWith( "!mutelist" ) )
{
string s = "^3Muted: ";
foreach ( Player player in MuteDb )
if ( player.Client == Client )
foreach ( ServerClient client in player.Muted )
s += client.Name + ", ";
TellClient( Client.ClientNum, s, true );
return ChatType.ChatContinue;
}
// Show the text to everyone that didn't mute this Client
foreach ( Player player in MuteDb )
if ( !player.IsMuted( Client ) )
TellClient( player.Client.ClientNum, Message, true );
return ChatType.ChatContinue;
}
// Get the 'Player' class for this client
Player GetPlayerMute( ServerClient client )
{
foreach ( Player player in MuteDb )
if ( player.Client == client )
return player;
return null;
}
// Get the 'ServerClient' for this player(name)
ServerClient GetClientByName( string name )
{
foreach ( ServerClient client in GetClients() )
if ( client.Name.StartsWith( name, StringComparison.InvariantCultureIgnoreCase )
|| client.Name.EndsWith( name, StringComparison.InvariantCultureIgnoreCase ) )
return client;
return null;
}
}
public class Player
{
public ServerClient Client;
public System.Collections.Generic.List<ServerClient> Muted = new System.Collections.Generic.List<ServerClient>();
public Player( ServerClient client ) { Client = client; }
public bool IsMuted( ServerClient client ) { return Muted.Contains( client ); }
public void AddMute( ServerClient client ) { Muted.Add( client ); }
public void RemoveMute( ServerClient client ) { Muted.Remove( client ); }
}
}(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
02-02-2012, 00:06
Ah nice, won't code one tomorrow then
![]() -Bonemind
02-02-2012, 00:11
(02-02-2012, 00:06)bonemind Wrote: Ah nice, won't code one tomorrow then Can you compile, test and debug it for me since I can't do this?
(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
02-02-2012, 00:15
02-02-2012, 06:02
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. |
| Users browsing this thread: |
| 1 Guest(s) |