Hi Guyz I have made a proper mute system
Features:
This Is An auto mute system and manual mute system you can mute anyone if you're admin and also you can mute anyone with timer mute cmd the player will be unmuted automatically after the given time and if player do spamming the player will be muted automatically and he will be unmuted in 30 seconds so enjoy the code ;)
Here is the source code
Put This Code in the top of main.nut
class MuteClass
{
MuteIndex = 0;
Timer = 0;
Muted = false;
}
Put This Code onScriptLoad
Mute <- array(GetMaxPlayers(), null); print("Mute System has been loaded successfully by MR_SK");
Put this code in onPlayerJoin
Mute[player.ID] = MuteClass();
Put this code onPlayerChat
if(Mute[player.ID].Muted == true && Mute[player.ID].Timer == 0){MessagePlayer("You Are Currently Muted!", player);return 0;}
if(Mute[player.ID].Muted == true && Mute[player.ID].Timer >0)
{
MessagePlayer("You Are Currently Muted For "+Mute[player.ID].Timer+" Mini Seconds!", player);return 0;
}
Mute[player.ID].MuteIndex += 1;
if(Mute[player.ID].MuteIndex == 4){Message("Auto Muted "+player.Name+" Time 30 seconds Reason: spamming"); Mute[player.ID].Muted = true; Mute[player.ID].Timer = 3000; NewTimer( "Unmute", 30000, 1, player.ID ); return 0;}
NewTimer( "RemoveMuteIndex", 3000, 1, player.ID );
Here are the commands
else if(cmd == "mute")
{
if(player.Name == "MR_SK") /*You Can use any thing here like checking if you are admin or not*/
{
if(text)
{
local plr = GetPlayer( GetTok( text, " ", 1 ) ), reason = GetTok( text, " ", 2, NumTok( text, " " ) );
if(plr)
{
if(reason)
{
if(Mute[plr.ID].Muted == false)
{
Mute[plr.ID].Muted = true;
Message("Admin: "+player.Name+" Has muted "+plr.Name+" Reason: "+reason+"");
}
else MessagePlayer("[#db0000]The player Is not muted yet!", player);
}
else MessagePlayer("[#db0000]You must the type the reason to mute the player!", player);
}
else MessagePlayer("[#db0000]The Requested User Is Not Present In Game!", player);
}
else MessagePlayer( "Syntax; /" + cmd + " <Player/ID> <Reason>", player );
}
else MessagePlayer("[#db0000]Unknown command.", player);
}
else if(cmd == "unmute")
{
if(player.Name == "MR_SK") /*You Can use any thing here like checking if you are admin or not*/
{
if(text)
{
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if(plr)
{
if(Mute[plr.ID].Muted == true)
{
Mute[plr.ID].Muted = false;
Message("Admin: "+player.Name+" Has unmuted "+plr.Name+"");
}
else MessagePlayer("[#db0000]The player Is not muted yet!", player);
}
else MessagePlayer("[#db0000]the player is not present in game!", player);
}
else MessagePlayer( "Syntax; /" + cmd + " <Player/ID>", player );
}
else MessagePlayer("[#db0000]Unknown command.", player);
}
else if(cmd == "timermute")
{
if(player.Name == "MR_SK") /*You Can use any thing here like checking if you are admin or not*/
{
if(text)
{
local plr = GetPlayer( GetTok( text, " ", 1 ) ), time = GetTok( text, " ", 2 ), reason = GetTok( text, " ", 3, NumTok( text, " " ) );
if(plr)
{
if(time)
{
if(IsNum(time))
{
if(reason)
{
if(Mute[plr.ID].Muted == false)
{
Mute[plr.ID].Muted = true;
Message("Admin: "+player.Name+" Has muted "+plr.Name+" Time: "+time.tointeger()+" Mini Seconds Reason: "+reason+"");
NewTimer( "Unmute", time.tointeger(), 1, player.ID );
Mute[player.ID].Timer = time.tointeger();
}
else MessagePlayer("[#db0000]The player Is not muted yet!", player);
}
else MessagePlayer("[#db0000]You must the type the reason to mute the player!", player);
}
else MessagePlayer("[#db0000]The time must be in numbers!", player);
}
else MessagePlayer("[#db0000]You must type the time for muting player!", player);
}
else MessagePlayer("[#db0000]The Requested User Is Not Present In Game!", player);
}
else MessagePlayer( "Syntax; /" + cmd + " <Player/ID> <Time> <Reason>", player );
}
else MessagePlayer("[#db0000]Unknown command.", player);
}
And Here Are the functions
function RemoveMuteIndex(plr)
{
local player = FindPlayer(plr);
if(player){Mute[player.ID].MuteIndex = 0;}
}
function Unmute(plr)
{
local player = FindPlayer(plr);
if(player){Message("Auto Unmuted "+player.Name+""); Mute[player.ID].Muted = false; Mute[player.ID].Timer = 0;}
}
function GetPlayer( plr )
{
if ( plr )
{
if ( IsNum( plr ) )
{
plr = FindPlayer( plr.tointeger() );
if ( plr ) return plr;
else return false;
}
else
{
plr = FindPlayer( plr );
if ( plr ) return plr;
else return false;
}
}
else return false;
}
function GetTok(string, separator, n, ...)
{
local m = vargv.len() > 0 ? vargv[0] : n,
tokenized = split(string, separator),
text = "";
if (n > tokenized.len() || n < 1) return null;
for (; n <= m; n++)
{
text += text == "" ? tokenized[n-1] : separator + tokenized[n-1];
}
return text;
}
function NumTok(string, separator)
{
local tokenized = split(string, separator);
return tokenized.len();
}
Tested!
Mini seconds?? WHAT?
Do you mean milliseconds (ms) ?
Quote from: WikipediaA millisecond (from milli- and second; symbol: ms) is a thousandth (0.001 or 10−3 or 1/1000) of a second. A unit of 10 milliseconds may be called a centisecond, and one of 100 milliseconds a decisecond, but these names are rarely used.
Quote from: Athanatos on Oct 09, 2021, 03:17 PMMini seconds?? WHAT?
Do you mean milliseconds (ms) ?
Quote from: WikipediaA millisecond (from milli- and second; symbol: ms) is a thousandth (0.001 or 10−3 or 1/1000) of a second. A unit of 10 milliseconds may be called a centisecond, and one of 100 milliseconds a decisecond, but these names are rarely used.
lol yeah but I want to get seconds from milli seconds so do you have it?
Quote from: MRSK143 on Oct 09, 2021, 04:53 PMQuote from: Athanatos on Oct 09, 2021, 03:17 PMMini seconds?? WHAT?
Do you mean milliseconds (ms) ?
Quote from: WikipediaA millisecond (from milli- and second; symbol: ms) is a thousandth (0.001 or 10−3 or 1/1000) of a second. A unit of 10 milliseconds may be called a centisecond, and one of 100 milliseconds a decisecond, but these names are rarely used.
lol yeah but I want to get seconds from milli seconds so do you have it?
The formula is
seconds = milliseconds / 1000
That's it. You divide milliseconds by 10^3.