Author Topic: UBan -- Global ban system. Ban users from all servers connected to a single DB!  (Read 99412 times)

0 Members and 4 Guests are viewing this topic.

Offline blackfire88

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 0
allright, i got it working, but now:
UBan failure. Error is: [@addons\uban\lua\autorun\server\uban.lua:158] Column 'serverip' cannot be null
Global ban failed! See server console for error.
ulx mytitle

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
allright, i got it working, but now:
UBan failure. Error is: [@addons\uban\lua\autorun\server\uban.lua:158] Column 'serverip' cannot be null
Global ban failed! See server console for error.
ulx mytitle

Oops, change your schema to allow the serverip column to be null (remove NOT NULL).
Experiencing God's grace one day at a time.

Offline blackfire88

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 0
D: Even more errors:

UBan failure. Error is: [@addons\uban\lua\autorun\server\uban.lua:137] MySQL server has gone away

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Try disabling sql persistence
Experiencing God's grace one day at a time.

Offline Juze

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
So, there's no chance to get this working on Linux with MySQL?

Offline talmera

  • Newbie
  • *
  • Posts: 36
  • Karma: 4
    • Tectonic-Gaming
*EDIT*

i got it working and is adding bans to the database :3

now to just make it so it shows the server ip it was made from
« Last Edit: April 29, 2012, 06:33:48 AM by talmera »
It's not a sin if it can't make me cry
He's not the devil unless there's fire in his eyes
It ain't the ghost if it don't speak in tongue
It's not a victory 'till the battles been won

Offline saintwubbles

  • Newbie
  • *
  • Posts: 15
  • Karma: 3
Modified it to work with MySQLOO and Garry's Mod 13. I've also changed it to use normal steamIDs.

Offline Cyborg_delta1

  • Newbie
  • *
  • Posts: 8
  • Karma: 1
Hmmm not working? I have every thing installed the MYsqloo module downloaded the updated version of this code. When I ban some one on the gban command it bans them from the server but there info is not on the database there are no errors when banning some one and no errors when the server starts up can any one help?

Edit....

Ok I put this after server.onConnected = function()

print( "Database has connected!" )

And as soon as the server starts up it prints "Database has connected!" but yet it still not putting the bans into the database?
« Last Edit: November 12, 2012, 01:17:20 PM by Cyborg_delta1 »

Offline saintwubbles

  • Newbie
  • *
  • Posts: 15
  • Karma: 3
It sounds like it's an issue with your database table based on the lack of lua errors. You will have to change the steamid field to be longer to accommodate the 'STEAM_' which the broken official release stripped out. Here is the modified table structure:

Code: [Select]
CREATE TABLE IF NOT EXISTS `gbans` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `steamid` char(20) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
  `name` char(31) CHARACTER SET latin1 COLLATE latin1_general_ci DEFAULT NULL,
  `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `unban_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `comment` char(128) DEFAULT NULL,
  `serverip` varchar(15) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
  `serverport` smallint(5) unsigned NOT NULL,
  `adminname` char(31) DEFAULT NULL,
  `adminsteamid` char(35) CHARACTER SET latin1 COLLATE latin1_general_ci DEFAULT NULL,
  UNIQUE KEY `id` (`id`),
  KEY `steamid` (`steamid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=812 ;

To debug it print() out the query and copy it into phpmyadmin/whatever you control your database with, that will let you see what is going wrong.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
I'm using saintwubbles version of this, but it seems to still not be sending the ban to the database.

I do !gban PLAYERNAME 1 reason it sure bans me for one minute, but it doesn't write it in the database.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
I just debugged the crap out of this, and I seem to get an error at line 188 which is at the end of the uban.lua.

I'm just going to post the whole function to see if anyone can find out why it's not working. If you need the uban.lua it's in a attachment


This is not the whole code
Code: [Select]
function DoBans()

local Qc = server:query("SELECT steamid, TIME_TO_SEC( TIMEDIFF( unban_time, NOW() ) ) as timeleft FROM " .. table .. " WHERE NOW() < unban_time OR unban_time = 0")
    Qc.onSuccess = function(data)
Msg("Successfully Connected - Line 138\n")
local results = data:getData()

local steamids = {}

for _, t in ipairs( results ) do
local steamid = t.steamid

local time = t.timeleft
if not time or time == 0 then
time = baninterval
else
time = math.min( time / 60, baninterval )
end

steamids[ steamid ] = math.max( time, steamids[ steamid ] or 0 ) -- We're doing this so oddly so we can catch multiple results and use the largest one.
end

-- We're using this following chunk of code to identify current steamids in the server
local cursteamids = {}
local players = player.GetAll()
for _, ply in ipairs( players ) do
cursteamids[ ply:SteamID() ] = ply
end

for steamid, time in pairs( steamids ) do -- loop through all currently banned ids
if cursteamids[ steamid ] then -- Currently connected
local str = string.format( "kickid %s Banned on global ban list\n", steamid )
game.ConsoleCommand( str )
Bans[ steamid ] = nil -- Clear their ban info to make sure they get banned. (A 'reban' should only ever arise if console removeid's a steamid)
end

if not Bans[ steamid ] or Bans[ steamid ] < time or Bans[ steamid ] > time + baninterval * 2 then -- If we don't already have them marked as banned or it's a new time
local str = string.format( "banid %f %s kick\n", time, steamid )
game.ConsoleCommand( str )
-- print( str ) -- For debug
end
Bans[ steamid ] = time
end

for steamid in pairs( Bans ) do -- loop through all recorded bans
if not steamids[ steamid ] then -- If they're not on the ban list we just pulled off the server, they're out of jail!
game.ConsoleCommand( "removeid " .. steamid .. "\n" )
Bans[ steamid ] = nil
end
end


end
Qc.onFailure = function(Err) print(Err) end
Msg("Failed to Connect - Line 188\n")
    Qc:start()



end



EDIT:

I tested it so more, and I found that the whole thing just "doesn't connect" let alone work. It just has problems connecting. I mean it's not like it ISN'T connecting, because if you make a bot it will say it successfully connected, but it just doesn't work.
« Last Edit: January 02, 2013, 12:23:23 AM by chaos13125 »
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Marmaduke

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
So, does anyone know how to get this working on Gmod13? when I ban myself it says i'm global banned, and when I try to reconnect it tells me i'm banned, except when I look at the database there is no new entry, even after the specified "0.25 minutes".
When I try to gbanid, it says:

"Global ban failed! See server console for error."

When the server console is checked it says:

"UBan failure. Error is: lua/autorun/server/uban.lua:96: attempt to index local 'Qc' (a nil value)"

I have no idea what this error is, nor how to fix it. 'Anyone know the fix? I'm using saintwubbles version.

Thanks

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
It doesn't work on gmod 13, this does.

Offline Moka

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
Cant seem to connect to my database. Even tried a different web host.

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
The last post on this by a ulysses member was in 2011. It doesn't work anymore. Go to the link I posted above and use that one, or try the sourcebans one, both work just fine.