local CATEGORY_NAME = "Sourcebans"
function ulx.sban( calling_ply, target_ply, minutes, reason )
if target_ply:IsBot() then
ULib.tsayError( calling_ply, "Cannot ban a bot", true )
return
end
calling_ply:ConCommand( "sm_ban #" .. target_ply:UserID() .. " " .. minutes .. " " .. (reason or "") )
local time = "for #i minute(s)"
if minutes == 0 then time = "permanently" end
local str = "#A sourcebanned #T " .. time
if reason and reason ~= "" then str = str .. " (#s)" end
ulx.fancyLogAdmin( calling_ply, str, target_ply, minutes ~= 0 and minutes or reason, reason )
end
local sban = ulx.command( CATEGORY_NAME, "ulx sban", ulx.sban, "!sban" )
sban:addParam{ type=ULib.cmds.PlayerArg }
sban:addParam{ type=ULib.cmds.NumArg, hint="minutes, 0 for perma", ULib.cmds.optional, ULib.cmds.allowTimeString, min=0 }
sban:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine, completes=ulx.common_kick_reasons }
sban:defaultAccess( ULib.ACCESS_ADMIN )
sban:help( "Bans target via sourcebans." )
function ulx.sbanid( calling_ply, steamid, minutes, reason )
steamid = steamid:upper()
if not ULib.isValidSteamID( steamid ) then
ULib.tsayError( calling_ply, "Invalid steamid." )
return
end
local name
local plys = player.GetAll()
for i=1, #plys do
if plys[ i ]:SteamID() == steamid then
name = plys[ i ]:Nick()
break
end
end
calling_ply:ConCommand( "sm_addban " .. minutes .. " " .. steamid .. " " .. (reason or "") )
local time = "for #i minute(s)"
if minutes == 0 then time = "permanently" end
local str = "#A sourcebanned steamid #s "
if name then
steamid = steamid .. "(" .. name .. ") "
end
str = str .. time
if reason and reason ~= "" then str = str .. " (#4s)" end
ulx.fancyLogAdmin( calling_ply, str, steamid, minutes ~= 0 and minutes or reason, reason )
end
local sbanid = ulx.command( CATEGORY_NAME, "ulx sbanid", ulx.sbanid )
sbanid:addParam{ type=ULib.cmds.StringArg, hint="steamid" }
sbanid:addParam{ type=ULib.cmds.NumArg, hint="minutes, 0 for perma", ULib.cmds.optional, ULib.cmds.allowTimeString, min=0 }
sbanid:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine, completes=ulx.common_kick_reasons }
sbanid:defaultAccess( ULib.ACCESS_SUPERADMIN )
sbanid:help( "Bans steamid via sourcebans." )
function ulx.sunban( calling_ply, steamid )
steamid = steamid:upper()
if not ULib.isValidSteamID( steamid ) then
ULib.tsayError( calling_ply, "Invalid steamid." )
return
end
calling_ply:ConCommand( "sm_unban " .. steamid )
ulx.fancyLogAdmin( calling_ply, "#A unbanned steamid #s", steamid )
end
local sunban = ulx.command( CATEGORY_NAME, "ulx sunban", ulx.sunban )
sunban:addParam{ type=ULib.cmds.StringArg, hint="steamid" }
sunban:defaultAccess( ULib.ACCESS_ADMIN )
sunban:help( "Unbans steamid via sourcebans." )
This should work, but I don't have sourcebans so I'm unable to test it.