Author Topic: Mute + Gag Time And Reason  (Read 3415 times)

0 Members and 1 Guest are viewing this topic.

Offline BlizzardyFire

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Mute + Gag Time And Reason
« on: December 12, 2017, 07:37:26 PM »
Hello, whenever I try doing this I somehow mess up or it doesn't work at all. I've looked all around on google but cannot find a solution. I've managed to get it to work with jailing (a reason) but i cant get a time or reason mutes + gags without it breaking, any help would be appreciated!

Code: [Select]
function ulx.gag( calling_ply, target_plys, time, reason, should_ungag )
local players = player.GetAll()
for i=1, #target_plys do
local v = target_plys[ i ]
v.ulx_gagged = not should_ungag
v:SetNWBool("ulx_gagged", v.ulx_gagged)
if not v.ulx_gagged then
timer.Create(v:SteamID64().."ulxgag", time, 1, function()
if not IsValid(v) then return end
v.ulx_gagged = not v.ulx_gagged
v:SetNWBool("ulx_gagged", v.ulx_gagged)
end)
else
timer.Destroy(v:SteamID64().."ulxgag")
v.ulx_gagged = not v.ulx_gagged
v:SetNWBool("ulx_gagged", v.ulx_gagged)
end
end

if not should_ungag then
local str = "#A gagged #T"
if seconds > 0 then
str = str .. " for #i seconds"
end
if reason and reason ~= "" then str = str .. " (#s)" end
ulx.fancyLogAdmin( calling_ply, str, target_plys, seconds, reason )
else
ulx.fancyLogAdmin( calling_ply, "#A ungagged #T", target_plys, reason )
end
end

local gag = ulx.command( CATEGORY_NAME, "ulx gag", ulx.gag, "!gag" )
gag:addParam{ type=ULib.cmds.PlayersArg }
gag:addParam{ type=ULib.cmds.NumArg, min=0, default=0, hint="seconds, 0 is forever", ULib.cmds.round, ULib.cmds.optional }
gag:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine, completes=ulx.common_kick_reasons }
gag:addParam{ type=ULib.cmds.BoolArg, invisible=true }
gag:defaultAccess( ULib.ACCESS_ADMIN )
gag:help( "Gag target(s), disables microphone." )
gag:setOpposite( "ulx ungag", {_, _, true}, "!ungag" )

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given