ULX

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

0 Members and 1 Guest are viewing this topic.

Offline blackfire88

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 0
Re: ULX & Sourcebans Integration
« Reply #15 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

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: ULX & Sourcebans Integration
« Reply #16 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.

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 #17 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)
« Last Edit: December 29, 2011, 07:51:04 AM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: ULX & Sourcebans Integration
« Reply #18 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.
« Last Edit: December 29, 2011, 11:38:36 PM by HeLLFox_15 »
I cry every time I see that I am not a respected member of this community.

Offline blackfire88

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 0
Re: ULX & Sourcebans Integration
« Reply #19 on: December 29, 2011, 05:07:21 PM »
Hellfox do you mind If i use that command you made in a ulx addon?

Offline blackfire88

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 0
Re: ULX & Sourcebans Integration
« Reply #20 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.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: ULX & Sourcebans Integration
« Reply #21 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.
I cry every time I see that I am not a respected member of this community.

Offline blackfire88

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 0
Re: ULX & Sourcebans Integration
« Reply #22 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.

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 #23 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.
« Last Edit: December 29, 2011, 08:03:18 PM by JamminR »
"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 #24 on: December 29, 2011, 08:05:26 PM »
Starting up my server now.. Ill test your code hellfox

Offline blackfire88

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 0
Re: ULX & Sourcebans Integration
« Reply #25 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?

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 #26 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.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: ULX & Sourcebans Integration
« Reply #27 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?
I cry every time I see that I am not a respected member of this community.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: ULX & Sourcebans Integration
« Reply #28 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.
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 #29 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. :)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming