Ulysses

Ulysses Stuff => General Chat & Help and Support => Topic started by: hymsan on November 18, 2011, 09:47:27 AM

Title: ULX & Sourcebans Integration
Post by: hymsan on November 18, 2011, 09:47:27 AM
I know this has been asked a lot, but I'm working on my own version of this now, with the sourcebans lua module that was recently updated on facepunch.

This is my edited ulx ban module.

Code: [Select]
function ulx.ban( 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 )
sourcebans.BanPlayer( target_ply, minutes*60, reason, calling_ply ) -- THIS IS THE SOURCEBANS INTEGRATION.

local time = "for #i minute(s)"
if minutes == 0 then time = "permanently" end
local str = "#A 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 ban = ulx.command( CATEGORY_NAME, "ulx ban", ulx.ban, "!ban" )
ban:addParam{ type=ULib.cmds.PlayerArg }
ban: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 }
ban:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine, completes=ulx.common_kick_reasons }
ban:defaultAccess( ULib.ACCESS_ADMIN )
ban:help( "Bans target." )

Everything works when I ban someone, except it doesn't return anything about the admin.

This is the sourcebans lua module "banplayer" function, in which I have being called from "ulx ban."

Code: [Select]
function BanPlayer(ply, time, reason, admin, callback)
callback = callback or blankCallback;
if (not checkConnection()) then
return callback(false, "No Database Connection");
elseif (not ply:IsValid()) then
error("Expected player, got NULL!", 2);
end
doBan(ply:SteamID(), getIP(ply), ply:Name(), time, reason, admin, callback);
end

This is where it makes the first request for admin details.

Code: [Select]
local function getAdminDetails(admin)
if (admin and admin:IsValid()) then
local data = admins[admin:SteamID()]
if (data) then
return data.aid, getIP(admin);
end
end
return 0, serverip;
end

And above is where it tries to get admin data (SteamID) to return to the sourcebans ban page, however it always returns Nil (which the sourcebans lua module reads as "CONSOLE")

I believe this is because of ulx's calling_ply and the fact that the sourcebans module requests a steamid from calling_ply.

I don't know where to go from here.


More information on the module can be located here: http://lexi.org.uk/modules/sourcebans.html
Title: Re: ULX & Sourcebans Integration
Post by: strategos on November 18, 2011, 09:40:26 PM
YES!

THIS IS BEING MADE!!!! (over-reaction?) I think not

Please release this to the public when finished. I'll love you forever.
Title: Re: ULX & Sourcebans Integration
Post by: LuaTenshi on November 18, 2011, 09:49:56 PM
Hmm, honestly I would try to make it separate, because when updates come, users will need to keep editing the main code for it to keep working.

But I would like in on this, I was actually thinking on using player.ConCommand (http://wiki.garrysmod.com/?title=Player.ConCommand) to call both commands, but after seeing this http://lexi.org.uk/modules/sourcebans.html I see how that can be implemented but, I still suggest that the commands should be separate.
Title: Re: ULX & Sourcebans Integration
Post by: hymsan on November 19, 2011, 04:48:02 AM
I'm actually looking for help on returning the SteamID of calling_ply in ULX, the sourcebans module was released by Lexic on facepunch, and is decently simple to integrate however with ulx there is no normal "ply" function in the util module.
Title: Re: ULX & Sourcebans Integration
Post by: LuaTenshi on November 19, 2011, 08:32:02 AM
I made a quick script to make sure every thing is working.

Code: [Select]
-- ULX steamcheck for ULX SVN/ULib SVN by HeLLFox_15
function ulx.steamcheck( calling_ply, target_plys, command )

local plSteamID = calling_ply:SteamID()
Msg(plSteamID .. "\n")
if(calling_ply and calling_ply:IsValid()) then Msg("Server: Entity Returned True\n") else Msg("Server: Entity Returned False\n") end
if(calling_ply) then Msg("Server: " .. calling_ply:Nick() .. "\n") else Msg("Server: Entity Returned False\n") end

ulx.fancyLogAdmin( calling_ply, "SteamID has been printed to Console", target_plys )

end
local steamcheck = ulx.command( "Utility", "ulx steamcheck", ulx.steamcheck, "!steamcheck" )
steamcheck:addParam{ type=ULib.cmds.PlayersArg }
steamcheck:defaultAccess( ULib.ACCESS_SUPERADMIN )
steamcheck:help( "steamcheck." )

And every thing seems to be working fine, the Steam ID is returning and all.
Title: Re: ULX & Sourcebans Integration
Post by: JamminR on November 19, 2011, 09:37:40 AM
hymsan,
First, I agree with others assessment.
You should write a totally separate ulx command structure so you (and other ULX users) don't have to edit ULX files every time ULX is updated on the local server.
All ULib (and therefore, ULX) commands have a hook method that will allow for intercepting commands, performing additional action, and then either stopping OR proceeding with the original command called.
In simplest terms, you could monitor, using a ULib command, for "ulx ban" and perform the sourceban function.
See ULibCommandCalled (http://ulyssesmod.net/docs/files/lua/ulib/shared/defines-lua.html#ULibCommandCalled) or ULibPostTranslatedCommand (http://ulyssesmod.net/docs/files/lua/ulib/shared/defines-lua.html#ULibPostTranslatedCommand)
Not only will that allow you to monitor ulx ban, it would allow you to write a totally separate, for instance  "ulx sban", command to use if for some reason you didn't want the normal ban function performed.

Second,
(I'm not the lua/Glua expert, but the below seems to me what is going on)
Where is your script being run from? If you're typing in that command on the server console, indeed, it will never find a steamid.
If from server console, you 'could' write in a config or something for you and the public that if detected from server console, place in the hosts SteamID instead.
Even if you're doing it from the client console, it's running as if on the server. Make sure you have your code files in /sh, and that they are running from the client side so that information should be passed (as Hyman's example worked).

I'd get second point working first, then aim for first point I made.
:)
Title: Re: ULX & Sourcebans Integration
Post by: strategos on November 19, 2011, 10:05:20 AM
It would be nice to incorporate this into xgui when finished. If anyone needs a test server I'd be happy to help.
Title: Re: ULX & Sourcebans Integration
Post by: LuaTenshi on November 25, 2011, 11:01:36 AM
OK I have made a script really fast, I did not test it yet because I do not want to install the source-bans stuff on to my client, plus Strategos or Sonicscream can always test for me. :P

Code: [Select]
-- ULX sban for ULX SVN/ULib SVN by HeLLFox_15
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 )
sourcebans.BanPlayer( target_ply, minutes*60, reason, calling_ply )

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." )

To install the script above make a folder with the following file path "garrysmod\addons\FolderName\lua\ulx\modules\sh"
Copy and paste the script into notepad then save as sh_sban.lua and move it into "garrysmod\addons\FolderName\lua\ulx\modules\sh".

Post what happens when you run the above script using "!sban <target> <time> <reason>".

( I do realize that I took the script from the first post and separated it into a separate command, but may be that is all that's needed. )

Side Note: I think some one should move this thread to "Developers Corner".
Title: Re: ULX & Sourcebans Integration
Post by: strategos on November 26, 2011, 01:24:47 PM
I have tried testing it and I couldn't get it to work. Now I'm not saying it is the scripts fault. I think that the current installment of sourcebans.lua has issues returning who is admin because even though I know I set up everything properly, the sm_ban still said I was unauthorized. http://www.facepunch.com/threads/980687?p=33438677&highlight=#post33438677
Apparently lexi is working on fixing it so I'll be happy give it another shot when it gets done. I haven looked too closely but if this is the only problem, it really doesn't why the script shouldn't work. Ulx registers the command fine but it won't ban or kick the player.
Title: Re: ULX & Sourcebans Integration
Post by: sonicscream on December 03, 2011, 11:10:46 AM
Before I can actually do anything useful for you, I'm going to have to find some free time before I can install SourceMod and get it running appropriately.
My apologies :P
Title: Re: ULX & Sourcebans Integration
Post by: blackfire88 on December 26, 2011, 11:39:00 PM
Hey hellfox,
I tried your code and it didn't work. Here is a  fixed version:
Code: [Select]
-- ULX sban for ULX SVN/ULib SVN by HeLLFox_15 (Fixed by 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 )
sourcebans.BanPlayer( target_ply, minutes*60, reason, calling_ply )

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." )
Title: Re: ULX & Sourcebans Integration
Post by: blackfire88 on December 26, 2011, 11:54:02 PM
Hmm. That still doesn't work 100%.
I tested it with a sourcebans web install and it seems that either the module doesn't work or calling_ply is a nil value.
I think it is the latter.
It doesn't get my admin id and add it into sourcebans.
Title: Re: ULX & Sourcebans Integration
Post by: LuaTenshi on December 27, 2011, 07:11:45 PM
Hey hellfox,
I tried your code and it didn't work.

Ah lol, my mistake, I put an unneeded "s" in there. I used http://diffchecker.com/ to check.
Title: Re: ULX & Sourcebans Integration
Post by: JamminR on December 27, 2011, 08:01:02 PM
I tested it with a sourcebans web install and it seems that either the module doesn't work or calling_ply is a nil value.

Where is your script being run from? If you're typing in that command on the server console, indeed, it will never find a steamid.
If from server console, you 'could' write in a config or something for you and the public that if detected from server console, place in the hosts SteamID instead.
Even if you're doing it from the client console, it's running as if on the server. Make sure you have your code files in /sh, and that they are running from the client side so that information should be passed (as Hyman's example worked).

Even back in mid-November, console steam id hasn't changed.
Not sure how I can make that more clear.
If the sourceban command is being called from server console, there is no steam id for it. You'd have to code in one in some way.
Title: Re: ULX & Sourcebans Integration
Post by: LuaTenshi on December 28, 2011, 03:13:52 AM
Even back in mid-November, console steam id hasn't changed.
Not sure how I can make that more clear.
If the sourceban command is being called from server console, there is no steam id for it. You'd have to code in one in some way.

What do you mean, because I am giving it the entity and thus the ID of the person who made the ban, and the entity of the person that is being banned...

Code: [Select]
sourcebans.BanPlayer( target_ply, minutes*60, reason, calling_ply )
Because on the same site that was provided I have read that the command works like so.

Quote
BanPlayer (ply, time, reason, admin, callback)

Bans a player by object

Parameters

ply: The player to ban
time: How long to ban the player for (in seconds)
reason: Why the player is being banned
admin: (Optional) The admin who did the ban. Leave nil for CONSOLE.
callback: (Optional) A function to call with the results of the ban. Passed true if it worked, false and a message if it didn't.

Plus if it cant find a SteamID, it should return nil, and be displayed as console, as it says above.
Title: Re: ULX & Sourcebans Integration
Post by: blackfire88 on December 28, 2011, 01:49:11 PM
I'm not sure how ULX works. Is calling_ply actually the entity that called the command? Or is it something else.
Also, I am having a problem where my sourcebans module isnt being run, and the config module is!
Any help
Title: Re: ULX & Sourcebans Integration
Post by: Aaron113 on December 28, 2011, 02:15:53 PM
calling_ply would be the entity that called the command, yes.  You can name it what ever you'd like though.  You are not limited to calling_ply.
Title: Re: ULX & Sourcebans Integration
Post by: JamminR on December 29, 2011, 07:42:58 AM
Hellfox, calling_ply (or as Aaron says, any variable name, we at Ulysses try to not obfuscate variable names) is indeed, also like Aaron says, the entity that called the command. If console calls the command, calling_ply isn't nil. ULib (or at least, ULX, I forget which at this time), does some fancy stuff to it to make it display as a name.
If my memory serves me right, console entid is 0 (I'm sure I could use Gmod wiki to look this up), other code would need to adjust for that.
As you may already know or need reminding, in lua code, 0 is not nil.
Hymsan's original post said that it was having trouble with showing or running due to issues with the admin being passed.
Code: [Select]
sourcebans.BanPlayer( target_ply, minutes*60, reason, calling_ply ) -- THIS IS THE SOURCEBANS INTEGRATION.
Code: [Select]
BanPlayer (ply, time, reason, admin, callback)
The Sourceban's function is most likely choking on the fact that "admin" in the variable field being passed isn't nil, if indeed it is being run from server (as I think it would need to be for Sourcebans)
Title: Re: ULX & Sourcebans Integration
Post by: LuaTenshi on December 29, 2011, 10:29:39 AM
JamminR, when the console runs the command does calling_ply:IsPlayer() return false?

Because if it does like I assume the following script should work.

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." )

Please notice the small block of code that I added before calling the sourcebans.BanPlayer function.

Code: [Select]
    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 )

I am going to get this tested later on in the day, and get back to this post with the results.
Title: Re: ULX & Sourcebans Integration
Post by: blackfire88 on December 29, 2011, 05:07:21 PM
Hellfox do you mind If i use that command you made in a ulx addon?
Title: Re: ULX & Sourcebans Integration
Post by: blackfire88 on December 29, 2011, 05:10:50 PM
Oh also that should work. But don't worry about that. If console calls the command, just use calling_ply because the modules detects if it is console or not.
IF it's console it will automatically set it as console. I am pretty sure there is a problem with the module in which it doesn't detect the right admin.
Title: Re: ULX & Sourcebans Integration
Post by: LuaTenshi on December 29, 2011, 07:32:07 PM
Hellfox do you mind If i use that command you made in a ulx addon?

In what ULX add-on?

Also, if you can please test the command for me.
Title: Re: ULX & Sourcebans Integration
Post by: blackfire88 on December 29, 2011, 07:42:13 PM
In what ULX add-on?
I'm making one with sourcebans commands.
It won't just be !ban !unban. I plan on having a !syncbans and other things.

Also, if you can please test the command for me.
Sorry, my server's down at the moment.
Title: Re: ULX & Sourcebans Integration
Post by: JamminR on December 29, 2011, 07:53:14 PM
just use calling_ply because the modules detects if it is console or not.
IF it's console it will automatically set it as console.

Blackfire, only ULX modules see that the calling_ply object is the console when called from server and automagically do something with it to tell other Ulib/ULX modules to treat it as such.
Sourcebans module being called here apparently doesn't do the same. Instead of the module recognizing the console entity object as what it is, it expects to be passed nil.

Hellfox, quick review, your code is more likely to work than before, at least in part of previous mentions of the original topic starter saying it handled recording admins oddly. Not sure you need the 'return', but, should work with it.

EDIT- additionally, here's code we use from ulx/lua/log.lua to determine console or not.
Code: [Select]
function ulx.logUserAct( ply, target, action, hide_echo )
local nick
if ply:IsValid() then
if not ply:IsConnected() or not target:IsConnected() then return end
nick = ply:Nick()
else
nick = "(Console)"
end
It's pretty clear the checks being done.
Title: Re: ULX & Sourcebans Integration
Post by: blackfire88 on December 29, 2011, 08:05:26 PM
Starting up my server now.. Ill test your code hellfox
Title: Re: ULX & Sourcebans Integration
Post by: blackfire88 on December 29, 2011, 08:08:33 PM
Oh one more thing guys.
When an admin uses the !sban command, the sourcebans module seems to have a problem where it thinks everyone is console.
Does anyone know of a fix for this?
Title: Re: ULX & Sourcebans Integration
Post by: JamminR on December 29, 2011, 11:24:02 PM
http://lexi.org.uk/modules/sourcebans.html isn't clear.
Does the "admin" as any part of those commands expected to be an admin's name? Admin's player object? Admin's steam id?
Really difficult to fix if the variable being passed is a guess.
Title: Re: ULX & Sourcebans Integration
Post by: LuaTenshi on December 29, 2011, 11:32:23 PM
Oh one more thing guys.
When an admin uses the !sban command, the sourcebans module seems to have a problem where it thinks everyone is console.
Does anyone know of a fix for this?

What errors do you get?
How exactly does it look?

Do you mean any one can run the command?

Can only admins use it but when they do they return as console?
Title: Re: ULX & Sourcebans Integration
Post by: LuaTenshi on December 29, 2011, 11:37:23 PM
http://lexi.org.uk/modules/sourcebans.html isn't clear.
Does the "admin" as any part of those commands expected to be an admin's name? Admin's player object? Admin's steam id?
Really difficult to fix if the variable being passed is a guess.

I belive its the player object, because in the following code. That was said to be taken from Sourcebans.

Code: [Select]
local function getAdminDetails(admin)
if (admin and admin:IsValid()) then
local data = admins[admin:SteamID()]
if (data) then
return data.aid, getIP(admin);
end
end
return 0, serverip;
end

IsValid() is being called on 'admin' in that case I assume its an entity.
Title: Re: ULX & Sourcebans Integration
Post by: JamminR on December 30, 2011, 12:25:06 AM
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. :)
Title: Re: ULX & Sourcebans Integration
Post by: LuaTenshi 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.
Title: Re: ULX & Sourcebans Integration
Post by: JamminR 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.
Title: Re: ULX & Sourcebans Integration
Post by: blackfire88 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.
Title: Re: ULX & Sourcebans Integration
Post by: JamminR 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.
Title: Re: ULX & Sourcebans Integration
Post by: Mooash 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  :-\
Title: Re: ULX & Sourcebans Integration
Post by: LuaTenshi 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.