General > Developers Corner

Sourceban Small integration error

(1/2) > >>

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

--- End code ---

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 !

Schiaffino:
After moving the function:


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

--- End code ---

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

Neku:
There are plenty of threads about this. Visit the links below.

You have banned (Console) permanently (reason)
How to update ULX (ULX beginner here!) and get the SVN?

Schiaffino:
The problem is that i'm using the latest revision from the github, downloaded today huh :/

Avoid:
Hello there, try this:

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

--- End code ---

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

Navigation

[0] Message Index

[#] Next page

Go to full version