Skip to content

Commit d00136c

Browse files
Added user failback
- Added a failback if the user doesnt exist, in that case we add the user to the database and then ban him of the server. Another bug was found but cannot be resolved as of now, the issue persists with ULX itself and we are awaiting responce by the ULX team
1 parent 31143e9 commit d00136c

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

lua/msync/server/modules/sv_mbsync.lua

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ MSync.modules = MSync.modules or {}
55
* @package MySQL Ban Sync
66
* @author Aperture Development
77
* @license root_dir/LICENSE
8-
* @version 1.0.1
8+
* @version 1.1.0
99
]]
1010

1111
--[[
@@ -15,7 +15,7 @@ local info = {
1515
Name = "MySQL Ban Sync",
1616
ModuleIdentifier = "MBSync",
1717
Description = "Synchronise bans across your servers",
18-
Version = "1.0.1"
18+
Version = "1.1.0"
1919
}
2020

2121
--[[
@@ -197,7 +197,6 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
197197
);
198198
]] )
199199
local timestamp = os.time()
200-
print(reason)
201200
banUserIdQ:setString(1, userid)
202201
banUserIdQ:setString(2, userid)
203202
banUserIdQ:setString(3, calling_ply)
@@ -248,15 +247,20 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
248247
end
249248

250249
banUserIdQ.onError = function( q, err, sql )
251-
print("------------------------------------")
252-
print("[MBSync] SQL Error!")
253-
print("------------------------------------")
254-
print("Please include this in a Bug report:\n")
255-
print(err.."\n")
256-
print("------------------------------------")
257-
print("Do not include this, this is for debugging only:\n")
258-
print(sql.."\n")
259-
print("------------------------------------")
250+
if string.match( err, "^Column 'user_id' cannot be null$" ) then
251+
MSync.mysql.addUserID(userid)
252+
MSync.modules[info.ModuleIdentifier].banUserID(userid, calling_ply, length, reason, allserver)
253+
else
254+
print("------------------------------------")
255+
print("[MBSync] SQL Error!")
256+
print("------------------------------------")
257+
print("Please include this in a Bug report:\n")
258+
print(err.."\n")
259+
print("------------------------------------")
260+
print("Do not include this, this is for debugging only:\n")
261+
print(sql.."\n")
262+
print("------------------------------------")
263+
end
260264
end
261265

262266
banUserIdQ:start()
@@ -1017,7 +1021,6 @@ MSync.modules[info.ModuleIdentifier].ulx = function()
10171021
calling_steamid = calling_ply:SteamID()
10181022
end
10191023
end
1020-
10211024
if not IsValid(target_ply) then return end
10221025

10231026
--[[
@@ -1089,12 +1092,11 @@ MSync.modules[info.ModuleIdentifier].ulx = function()
10891092
end
10901093
end
10911094

1092-
reason = reason or "No reason given"
1095+
reason = reason or "(None given)"
10931096

10941097
--[[
10951098
Run ban function with given functions
10961099
]]
1097-
10981100
MSync.modules[info.ModuleIdentifier].banUserID(target_steamid, calling_steamid, length, reason, allserver)
10991101

11001102
end
@@ -1296,6 +1298,10 @@ MSync.modules[info.ModuleIdentifier].hooks = function()
12961298
time = ban.timestamp
12971299
}
12981300

1301+
if ban.length == 0 then
1302+
banData["unban"] = ban.length
1303+
end
1304+
12991305
local message = ULib.getBanMessage( ban.banned.steamid, banData)
13001306
return false, message
13011307
else

0 commit comments

Comments
 (0)