function scc.joinChannel( calling_ply, target_ply, channel, is_force )
if not target_ply then target_ply = calling_ply end
local old = target_ply:GetChannel()
local players = SCC.PlayersInChannel( target_ply:GetChannel() )
local newPlayers = SCC.PlayersInChannel( channel )
local can, err = SCC.CanPlayerJoin( target_ply, channel )
if not can then
ULib.tsayError( calling_ply, "[SCC Error] You cannot perform this action: " .. err, true )
end
if not is_force then
calling_ply:JoinChannel( channel, false )
ulx.fancyLogAdmin( calling_ply, { calling_ply }, SCC.JoinMessage, channel )
ulx.fancyLogAdmin( calling_ply, { players }, SCC.LeaveMessage )
ulx.fancyLogAdmin( calling_ply, { newPlayers }, SCC.JoinedMessage )
else
calling_ply:JoinChannel( channel, true )
ulx.fancyLogAdmin( calling_ply, { calling_ply }, SCC.ForceMessage, target_ply, channel )
ulx.fancyLogAdmin( calling_ply, { players }, SCC.LeaveMessage )
ulx.fancyLogAdmin( calling_ply, { target_ply }, SCC.ForcedMessage, channel )
end
end
local sjoin = ulx.command( "SVC Utility", "svc joinchannel", scc.joinChannel, "!joinchannel" )
sjoin:addParam{ type = ULib.cmds.PlayerArg, ULib.cmds.optional, default = "^" }
sjoin:addParam{ type = ULib.cmds.StringArg, completes = scc.channels, ULib.cmds.restrictToCompletes, error = "Invalid channel \"%s\" specified." }
sjoin:addParam{ type = ULib.cmds.BoolArg, invisible = true }
sjoin:setOpposite( "svc force", { _, _, _, true }, "!forcejoin" )
sjoin:help( "Joins a specified channel." )
sjoin:defaultAccess( "user" )