Skip to content

Commit 4f56b80

Browse files
Merge pull request #69 from Aperture-Development/development
Bugfix update v1.3.1
2 parents 264f776 + df771db commit 4f56b80

File tree

3 files changed

+45
-13
lines changed

3 files changed

+45
-13
lines changed

lua/msync/server/modules/sv_mbsync.lua

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,29 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
660660
- Create User
661661
- Create ban query
662662
]]
663+
--[[
664+
Add user transaction
665+
]]
666+
transactions[k..'_user'] = MSync.DBServer:prepare( [[
667+
INSERT INTO `tbl_users` (steamid, steamid64, nickname, joined)
668+
VALUES (?, ?, ?, ?)
669+
ON DUPLICATE KEY UPDATE steamid=steamid;
670+
]] )
671+
transactions[k..'_user']:setString(1, k)
672+
transactions[k..'_user']:setString(2, util.SteamIDTo64( k ))
673+
if ULib.ucl.users[k] then
674+
transactions[k..'_user']:setString(3, ULib.ucl.users[k].name or 'None Given')
675+
else
676+
transactions[k..'_user']:setString(3, 'None Given')
677+
end
678+
transactions[k..'_user']:setString(4, os.date("%Y-%m-%d %H:%M:%S", os.time()))
679+
680+
banTransaction:addQuery(transactions[k..'_user'])
681+
MSync.log(MSYNC_DBG_DEBUG, "[MBSync] Import Bans: added create user transaction for: " .. k)
682+
683+
--[[
684+
Add ban transaction
685+
]]
663686
transactions[k] = MSync.DBServer:prepare( [[
664687
INSERT INTO `tbl_mbsync` (user_id, admin_id, reason, date_unix, length_unix, server_group)
665688
VALUES (
@@ -703,6 +726,7 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
703726

704727
banTransaction:addQuery(transactions[k])
705728
MSync.log(MSYNC_DBG_INFO, "[MBSync] Imported ban for SteamID: " .. k)
729+
MSync.log(MSYNC_DBG_DEBUG, "[MBSync] Import Bans: added create ban transaction for: " .. k)
706730
end
707731

708732
banTransaction.onSuccess = function()
@@ -786,10 +810,6 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
786810
]]
787811
MSync.modules[info.ModuleIdentifier].loadSettings()
788812

789-
if not MSync.modules[info.ModuleIdentifier].banTable then
790-
MSync.log(MSYNC_DBG_WARNING, "[MBSync] Ban table not found yet, requesting now")
791-
MSync.modules[info.ModuleIdentifier].getActiveBans()
792-
end
793813
end
794814

795815
--[[
@@ -806,7 +826,7 @@ MSync.modules[info.ModuleIdentifier].net = function()
806826
]]
807827
util.AddNetworkString("msync."..info.ModuleIdentifier..".sendMessage")
808828
MSync.modules[info.ModuleIdentifier].msg = function(ply, content, msgType)
809-
MSync.log(MSYNC_DBG_DEBUG, "[MBSync] Exec: MBSync.msg Param.: $ply \"$content\" $msgType")
829+
MSync.log(MSYNC_DBG_DEBUG, MSync.formatString("[MBSync] Exec: MBSync.msg Param.: $ply \"$content\" $msgType",{['ply'] = ply, ['content'] = content, ['msgType'] = msgType}))
810830
if type(ply) == "string" and not (ply == "STEAM_0:0:0") then
811831
ply = player.GetBySteamID( ply )
812832
end
@@ -1371,13 +1391,6 @@ end
13711391
Define hooks your module is listening on e.g. PlayerDisconnect
13721392
]]
13731393
MSync.modules[info.ModuleIdentifier].hooks = function()
1374-
--[[
1375-
This hook starts the timers for the asynchronous ban data loading and the check if one of the online players has been banned
1376-
]]
1377-
timer.Create("msync."..info.ModuleIdentifier..".getActiveBans", MSync.modules[info.ModuleIdentifier].settings.syncDelay, 0, function()
1378-
MSync.modules[info.ModuleIdentifier].getActiveBans()
1379-
end)
1380-
MSync.modules[info.ModuleIdentifier].getActiveBans()
13811394

13821395
hook.Add("CheckPassword", "msync."..info.ModuleIdentifier..".banCheck", function( steamid64 )
13831396
MSync.log(MSYNC_DBG_DEBUG, "[MBSync] Checking ban status for \"" .. steamid64 .. "\"")
@@ -1501,6 +1514,22 @@ MSync.modules[info.ModuleIdentifier].hooks = function()
15011514
end
15021515
MSync.modules[info.ModuleIdentifier].unBanUser(steamid, admin_id)
15031516
end)
1517+
1518+
hook.Add("MSyncModuleLoaded", "msync.mbsync.loadData", function( msync_module )
1519+
if (not msync_module or msync_module == info.ModuleIdentifier) and not MSync.modules[info.ModuleIdentifier].banTable then
1520+
if not MSync.modules[info.ModuleIdentifier].banTable then
1521+
MSync.log(MSYNC_DBG_WARNING, "[MBSync] Ban table not found yet, requesting now")
1522+
MSync.modules[info.ModuleIdentifier].getActiveBans()
1523+
end
1524+
1525+
--[[
1526+
Start timer to asynchroniously resync data
1527+
]]
1528+
timer.Create("msync."..info.ModuleIdentifier..".getActiveBans", MSync.modules[info.ModuleIdentifier].settings.syncDelay, 0, function()
1529+
MSync.modules[info.ModuleIdentifier].getActiveBans()
1530+
end)
1531+
end
1532+
end)
15041533
end
15051534

15061535
--[[

lua/msync/server/sv_modules.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function MSync.initModules()
4545

4646
function initTransaction.onSuccess()
4747
MSync.log(MSYNC_DBG_INFO, "Module querys have been completed successfully")
48+
hook.Call("MSyncModuleLoaded", nil, nil)
4849
MSync.mysql.dbstatus = true
4950
end
5051

@@ -77,6 +78,7 @@ function MSync.loadModule(path)
7778

7879
function initTransaction.onSuccess()
7980
MSync.log(MSYNC_DBG_INFO, "Module query has been completed successfully")
81+
hook.Call("MSyncModuleLoaded", nil, info.ModuleIdentifier)
8082
--MSync.mysql[info.ModuleIdentifier].dbstatus = true
8183
end
8284

@@ -109,6 +111,7 @@ function MSync.enableModule( module )
109111
function initTransaction.onSuccess()
110112
MSync.log(MSYNC_DBG_INFO, "["..MSync.modules[module]["info"]["Name"].."] Module loaded")
111113
MSync.net.sendModuleEnable( module )
114+
hook.Call("MSyncModuleLoaded", nil, module)
112115
--MSync.mysql[module].dbstatus = true
113116
end
114117

lua/msync/server/sv_mysql.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ end
148148
Returns: nothing
149149
]]
150150
function MSync.mysql.addUserID(steamid, nickname)
151-
MSync.log(MSYNC_DBG_DEBUG, "Exec: addUserID. Param.: " .. steamid .. " " .. nickname)
151+
MSync.log(MSYNC_DBG_DEBUG, "Exec: addUserID. Param.: " .. steamid .. " " .. (nickname or ""))
152152
if not MSync.DBServer then MSync.log(MSYNC_DBG_DEBUG, "No Database connected yet. Please connect to a Database to be able to create users."); return end;
153153
if not string.match( steamid, "^STEAM_[0-1]:[0-1]:[0-9]+$" ) then return end;
154154

0 commit comments

Comments
 (0)