@@ -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
793813end
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]]
13731393MSync .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 )
15041533end
15051534
15061535--[[
0 commit comments