Author Topic: Sourcebans and ULX  (Read 1977 times)

0 Members and 1 Guest are viewing this topic.

Offline LeviN

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Sourcebans and ULX
« on: March 27, 2020, 10:23:13 AM »
Hey guys. Was not sure if this was the place to post this but could use some help with the latest sourcebans ++ and a sourcebans lua script.

I currently use: https://github.com/blastehh/AnotherULXSBanModule
Using the latest mysqloo and have the script in place from tmpsql to convert everything to mysqloo following some threads.

I currently have been reproducing these errors every day, at the start of map change only.

Errors presented : https://pastebin.com/GWSsRMLn
Now it bans users and goes into the database without any issue. It does not pick up the bans from the webhost/database and show them in the menu that the script creates. Could anyone be able to help out? Completely new to this and its a learning process for me.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 802
  • Karma: 58
Re: Sourcebans and ULX
« Reply #1 on: March 27, 2020, 02:00:57 PM »
Replied on Discord but will post here too for anyone else:

https://github.com/blastehh/AnotherULXSBanModule/blob/master/garrysmod/addons/anotherulxsbanmodule/lua/ulx/modules/sban.lua#L308

This is the root of the first error. Looking at the source, SBAN_SQL_Query doesn't always return a value, but when it does it returns a function: https://github.com/blastehh/AnotherULXSBanModule/blob/master/garrysmod/addons/anotherulxsbanmodule/lua/ulx/modules/sban.lua#L150

The function SBAN_canunban (which is the function where the error is thrown at line 308) returns #SBAN_SQL_Query(query, qTab) > 0, but since SBAN_SQL_Query either returns nil or a function, the length operator (#) throws an error.
So, I think, if I understand the code right, if you change line 308 from return #SBAN_SQL_Query(query, qTab) > 0 to return #(SBAN_SQL_Query(query, qTab)(query)) > 0. Notice the extra parameter call to the function return.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Sourcebans and ULX
« Reply #2 on: March 27, 2020, 03:42:21 PM »
Also - in issue tracker of project, dev explains what is expected to be returned.
https://github.com/blastehh/AnotherULXSBanModule/issues/16#issuecomment-245778459
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 802
  • Karma: 58
Re: Sourcebans and ULX
« Reply #3 on: March 29, 2020, 03:06:47 AM »
Also - in issue tracker of project, dev explains what is expected to be returned.
https://github.com/blastehh/AnotherULXSBanModule/issues/16#issuecomment-245778459

Thanks :)

I'm currently trying to understand the script and I'm beginning to understand how it functions. I've worked through how the SQL data is returned (it's returned as a table of tables of tables, very convoluted IMO) but I'm figuring it out.

I'll post back here once everything is fixed! There were more bugs than just the one stated here.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given