Author Topic: ULX & Sourcebans Integration  (Read 19446 times)

0 Members and 1 Guest are viewing this topic.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: ULX & Sourcebans Integration
« Reply #30 on: December 30, 2011, 11:11:20 PM »
I'm making one with sourcebans commands.
It won't just be !ban !unban. I plan on having a !syncbans and other things.
Sorry, my server's down at the moment.

No I don't mind as long as you give me, and every one who helped credit.

Also I recommend that you use console commands for things like syncing admins, maybe some thing like "sbu_sync_admins"

-----------------

Code: [Select]
local data = admins[admin:SteamID()]
That line could be troublesome.

If the module is loading a table of Sourceban admins, and attempting to look the admin up using his/her steamid, then any admin with the ULX sban command access would also need Sourceban access 'if' the host wanted to know who was banning people, else, data will always be nil and return 'console' and server ip address.

I could dig further, but leave that to you fine folks. :)

Here is the full code for lexi's sourcebans.lua

http://lexi.org.uk/modules/sourcebans.lua

I don't see where or how its getting the admins table.
« Last Edit: December 30, 2011, 11:36:01 PM by HeLLFox_15 »
I cry every time I see that I am not a respected member of this community.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULX & Sourcebans Integration
« Reply #31 on: December 31, 2011, 12:16:40 AM »
http://lexi.org.uk/modules/sourcebans.lua

I don't see where or how its getting the admins table.

Two specific areas I see.
The database query is set up first apparently. I say 'apparently' because 1) I don't know the gm_mysqloo lua syntax. 2) I don't know SQL from scratch (I'm just decent at reading code/queries related to SQL)
 In --[[ Tables ]]--,  -- Admins
Code: [Select]
    ["Select Admins"] = "SELECT a.aid, a.user, a.authid, a.srv_group, a.srv_flags, a.immunity FROM %s_admins a, %s_admins_servers_groups g WHERE g.server_id = %i AND g.admin_id = a.aid";And the actual function that seems to read / use that data; under "--[[ Query Functions ]]--"
It sets the data local, and the function is titled loadadmins.
Code: [Select]
function loadAdmins()
    admins = {};
    adminGroups = {};
    adminsByID = {};
    local query = database:query(queries["Select Admin Groups"]:format(config.dbprefix));
    query.onFailure = adminGroupLoaderOnFailure;
    query.onSuccess = adminGroupLoaderOnSuccess;
    query:start();
    notifymessage("Loading Admin Groups . . .");
end

So, summarized, with what little I know of SQL and GM SQLOO syntax, but what I do know of lua, it seems that code expects any "admin" passed to the admin variable sourceban command to be an admin in Sourcebans too. Otherwise, Sourceban's ignores them, sets it as nil, which then makes it 'console' set the ban.

Best, but not necessarily easiest way, to work around that, would be to have Lexic modify to allow the API to pass non sourcebans admins, and validate/look the player object up when passed.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline blackfire88

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 0
Re: ULX & Sourcebans Integration
« Reply #32 on: January 03, 2012, 10:05:05 PM »
Okay, I don't quite understand what you are trying to say,
IF you mean to parse admins that aren't added to that server, then yes, that is possible.
If you mean to parse admins that arent on sourcebans, that is impossible, because of the way soucebans works.
I haven't found a way to get admin identities working, but that could be done fairly soon if I need to.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULX & Sourcebans Integration
« Reply #33 on: January 04, 2012, 05:01:27 PM »
Uh, blackfire = Lexic?
I'm so confused.

All I'm responding to is the discussion regarding the original post, and anyone else here, trying to get Sourcebans to list the name of the ULX admin instead of the [console].
From my understanding of the code, and what blackfire says;
Though it's possible to ban using the Glua module, It's not possible to show who did the ban unless the admin being passed is also registered as a Sourceban's admin.
ULX SB module CAN be made to work, but only if the addon user is willing to accept those facts.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Mooash

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
    • LiequidGaming.com
Re: ULX & Sourcebans Integration
« Reply #34 on: January 15, 2012, 06:08:10 PM »
Is there an update on whether this works or not yet? I get confused with all the versions of the code flying around  :-\

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: ULX & Sourcebans Integration
« Reply #35 on: January 16, 2012, 07:09:36 AM »
Is there an update on whether this works or not yet? I get confused with all the versions of the code flying around  :-\

This is the working code. (Admins who are not listed in source bans will show up as console, if they make a ban.)

Code: [Select]
-- ULX sban for ULX SVN/ULib SVN by HeLLFox_15
-- Special Thanks to: Hymsan, JamminR, Strategos, Sonicscream, and Blackfire88
function ulx.sban( calling_ply, target_ply, time, reason )

if target_ply:IsBot() then
ULib.tsayError( calling_ply, "Cannot ban a bot", true )
return
end

local minutes = ULib.stringTimeToSeconds( time )
if not minutes then
ULib.tsayError( calling_ply, "Invalid time format." )
return
end

ULib.kickban( target_ply, minutes, reason, calling_ply )
   
    local calling_admin = calling_ply
    if not calling_ply:IsPlayer() then
        calling_admin = nil
        return
    end
   
sourcebans.BanPlayer( target_ply, minutes*60, reason, calling_admin )

local time = "for #i minute(s)"
if minutes == 0 then time = "permanently" end
local str = "#A source banned #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( "Utility", "ulx sban", ulx.sban, "!sban" )
sban:addParam{ type=ULib.cmds.PlayerArg }
sban:addParam{ type=ULib.cmds.StringArg, hint="minutes, 0 for perma. 'h' for hours, 'd' for days, 'w' for weeks. EG, '2w5d' for 2 weeks 5 days", ULib.cmds.optional }
sban:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine, completes=ulx.common_kick_reasons }
sban:defaultAccess( ULib.ACCESS_SUPERADMIN )
sban:help( "Bans a target and adds them to the source bans list." )

Sorry for the confusion.
I cry every time I see that I am not a respected member of this community.