Ulysses Stuff > Ulysses Release Archives
Sourcebans integration
iSnipeu:
--- Code: ---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." )
--- End code ---
This should work, but I don't have sourcebans so I'm unable to test it.
Tristian Wood:
--- Quote from: iSnipeu on November 04, 2012, 09:24:12 PM ---
--- Code: ---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." )
--- End code ---
This should work, but I don't have sourcebans so I'm unable to test it.
--- End quote ---
I'll test it, but where do I put it?
iSnipeu:
lua\ulx\modules\sh\sourcebans.lua
ZachPL:
Alright first of all thanks for the help, but I am slightly confused on how this works...
Does this module require sourcemod in order to function correctly and if so I thought sourcemod is not compatible with gmod13. This is what is currently showing trying to use console command sm_ban
http://cloud-2.steampowered.com/ugc/939259113205840370/5E99A66529982528E85EE1A9F5DCCB4DC32E25BC/
Also the xgui part seems to be a little bit funky.
Stickly Man!:
--- Quote from: ZachPL on November 05, 2012, 05:30:54 AM ---Also the xgui part seems to be a little bit funky.
--- End quote ---
Yeah.. one of these days I'll get around to fixing that.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version