function ulx.mute( calling_ply, target_plys, minutes, should_unmute )
for i=1, #target_plys do
local v = target_plys[ i ]
if timer.Exists( v:SteamID() .. "UnmuteTimer" ) then
timer.Remove( v:SteamID() .. "UnmuteTimer" )
end
if should_unmute then
v.gimp = nil
v:SetNWBool( "ulx_muted", false ) --not sure why you've done this, it can be compressed with v:SetNWBool("ulx_muted", not should_unmute) just fine
else
v.gimp = 2
v:SetNWBool( "ulx_muted", true ) --not sure why you've done this, it can be compressed with v:SetNWBool("ulx_muted", not should_unmute) just fine
if minutes > 0 then --you did fix the sign here
timer.Create( v:SteamID() .. "UnmuteTimer", minutes * 60, 0, function()
RunConsoleCommand( "ulx", "unmute", v:Name() ) -- running this command is time wasting, you could just set v.gimp to nil and v:SetNWBool( "ulx_muted", false ) because that is all the unmute command does
end )
end
end
end
local time = "for #i minute(s)"
if minutes == 0 then time = "pemanently" end
local str = "#A muted #T " .. time
if not should_unmute then
ulx.fancyLogAdmin( calling_ply, str, target_plys, minutes )
else
ulx.fancyLogAdmin( calling_ply, "#A unmuted #T", target_plys )
end
end
local mute = ulx.command( "Utility", "ulx mute", ulx.mute, "!mute" )
mute:addParam{ type=ULib.cmds.PlayersArg }
mute:addParam{ type=ULib.cmds.NumArg, hint="minutes, 0 for perma", ULib.cmds.optional, ULib.cmds.allowTimeString, min=0 }
mute:addParam{ type=ULib.cmds.BoolArg, invisible=true }
mute:defaultAccess( ULib.ACCESS_ADMIN )
mute:help( "Mutes target(s) so tihey are unable to chat for a certain amount of minutes." )
mute:setOpposite( "ulx unmute", {_, _, _, true}, "!unmute" )