ULX

Author Topic: Sourceban Small integration error  (Read 3115 times)

0 Members and 1 Guest are viewing this topic.

Offline Schiaffino

  • Jr. Member
  • **
  • Posts: 88
  • Karma: 1
Sourceban Small integration error
« on: November 28, 2014, 07:02:15 PM »
Hello guys, well i've seen all the threadas about sourceban here and none of them solve my issue so im wondering if someone can help me to figure this out ?

Code: [Select]
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
SBAN.Player_Ban( target_ply, minutes*60, reason, calling_ply:SteamID() )

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
ULib.queueFunctionCall( ULib.addBan, target_ply, minutes, reason, name, calling_ply )
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." )

This code works 95% the only issue is that when you ban the user instead of giving the user name gives this



And this small error at the console huh



Sorry for bothering you about this guys but nay help,

Really thanks !

Offline Schiaffino

  • Jr. Member
  • **
  • Posts: 88
  • Karma: 1
Re: Sourceban Small integration error
« Reply #1 on: November 28, 2014, 07:24:04 PM »
After moving the function:

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

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 )
ULib.queueFunctionCall( ULib.addBan, target_ply, minutes, reason, name, calling_ply )
SBAN.Player_Ban( target_ply, minutes*60, reason, calling_ply:SteamID() )

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

To this position, it works but at sourceban's says "E" ( expired ) inmediately and still the same console error ID error....

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: Sourceban Small integration error
« Reply #2 on: November 28, 2014, 10:44:45 PM »
Out of the Garry's Mod business.

Offline Schiaffino

  • Jr. Member
  • **
  • Posts: 88
  • Karma: 1
Re: Sourceban Small integration error
« Reply #3 on: November 28, 2014, 11:34:52 PM »
The problem is that i'm using the latest revision from the github, downloaded today huh :/

Offline Avoid

  • Full Member
  • ***
  • Posts: 142
  • Karma: 42
Re: Sourceban Small integration error
« Reply #4 on: November 29, 2014, 05:40:58 AM »
Hello there, try this:
Code: [Select]
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

        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 )

        if calling_ply:IsValid() then
                SBAN.Player_Ban( target_ply, minutes*60, reason, calling_ply:SteamID() )
        else
                SBAN.Player_Ban( target_ply, minutes*60, reason, "STEAM_ID_SERVER")
        end

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

For sourcebans: Try banning longer than a minute and see if the ban expires immediately.

EDIT:
Also in your queued function call, try using the targeted player SteamID instead of the target player. See addBan

Avoid
« Last Edit: November 29, 2014, 05:46:32 AM by Avoid »

Offline Schiaffino

  • Jr. Member
  • **
  • Posts: 88
  • Karma: 1
Re: Sourceban Small integration error
« Reply #5 on: November 29, 2014, 11:27:22 AM »
Thanks Avoid! did it to implement it to the xgui menu and it works without the ID error now.

The only issue im having is that at SB website its showing "Expire" Inmediately :/ i'll make a few attempts
« Last Edit: November 29, 2014, 04:29:05 PM by Schiaffino »

Offline Schiaffino

  • Jr. Member
  • **
  • Posts: 88
  • Karma: 1
Re: Sourceban Small integration error
« Reply #6 on: November 29, 2014, 11:54:20 AM »
EDIT: Works perfect no ID error but when i set less than 5 hours for some reason it says "E

Really thanks for the quick reply !
« Last Edit: November 29, 2014, 04:05:52 PM by Schiaffino »

Offline Avoid

  • Full Member
  • ***
  • Posts: 142
  • Karma: 42
Re: Sourceban Small integration error
« Reply #7 on: November 30, 2014, 03:32:10 AM »
Hello there,
this is indeed a weird error, make sure you actually use the correct timezone in sourcebans and have a look through your code to see if the time is inserted correctly into the database.

Avoid