Skip to content

Commit 04e0dad

Browse files
Change ban behaviour
Editing bans now always adds the time to the current ban length. Meaning if I edit a ban 30 minutes after it was created with 1 hour of ban time, the ban length will be 1 hour 30 minutes, so that the user gets unbanned 1 hour after the edit happened
1 parent 4513962 commit 04e0dad

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

lua/msync/client_gui/cl_admin_gui.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ function MSync.AdminPanel.InitMySQL( sheet )
243243
end
244244
end
245245

246-
if MSync.settings ~= nil then
246+
if MSync.settings and MSync.settings.mysql then
247247
mysqlip:SetText(MSync.settings.mysql.host)
248248
mysqlport:SetText(MSync.settings.mysql.port)
249249
mysqldb:SetText(MSync.settings.mysql.database)

lua/msync/client_gui/modules/cl_mbsync.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,7 @@ MSync.modules[info.ModuleIdentifier].adminPanel = function(sheet)
878878
reload_button.DoClick = function()
879879
MSync.log(MSYNC_DBG_INFO, "[MBSync] Reloading data");
880880
MSync.modules[info.ModuleIdentifier].getBanTable(true)
881+
ban_table:Clear()
881882

882883
timer.Create("msync.mbsync.waitForBanTable", 1, 0, function()
883884
if MSync.modules[info.ModuleIdentifier].temporary["unfinished"] then return end

lua/msync/server/modules/sv_mbsync.lua

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,10 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
113113

114114
if MSync.modules[info.ModuleIdentifier].banTable[ply:SteamID64()] then
115115
MSync.log(MSYNC_DBG_INFO, "[MBSync] User \"" .. ply:SteamID64() .. "\" is already banned, editing old ban instead")
116-
if length ~= 0 then
117-
length = ((os.time() - MSync.modules[info.ModuleIdentifier].banTable[ply:SteamID64()].timestamp) + (length * 60)) / 60
118-
end
116+
-- Editing bans now always adds the time to the current ban length. Meaning if I edit a ban 30 minutes after it was created with 1 hour of ban time, the ban length will be 1 hour 30 minutes, so that the user gets unbanned 1 hour after the edit happened
117+
--if length ~= 0 then
118+
-- length = ((os.time() - MSync.modules[info.ModuleIdentifier].banTable[ply:SteamID64()].timestamp) + (length * 60)) / 60
119+
--end
119120
MSync.modules[info.ModuleIdentifier].editBan( MSync.modules[info.ModuleIdentifier].banTable[ply:SteamID64()]["banId"], reason, length, calling_ply, allserver)
120121
return
121122
end
@@ -201,9 +202,10 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
201202

202203
if MSync.modules[info.ModuleIdentifier].banTable[util.SteamIDTo64(userid)] then
203204
MSync.log(MSYNC_DBG_INFO, "[MBSync] User \"" .. userid .. "\" is already banned, editing old ban instead")
204-
if (length ~= 0) then
205-
length = ((os.time() - MSync.modules[info.ModuleIdentifier].banTable[util.SteamIDTo64(userid)].timestamp) + (length * 60)) / 60
206-
end
205+
-- Editing bans now always adds the time to the current ban length. Meaning if I edit a ban 30 minutes after it was created with 1 hour of ban time, the ban length will be 1 hour 30 minutes, so that the user gets unbanned 1 hour after the edit happened
206+
--if (length ~= 0) then
207+
-- length = ((os.time() - MSync.modules[info.ModuleIdentifier].banTable[util.SteamIDTo64(userid)].timestamp) + (length * 60)) / 60
208+
--end
207209
MSync.modules[info.ModuleIdentifier].editBan( MSync.modules[info.ModuleIdentifier].banTable[util.SteamIDTo64(userid)]["banId"], reason, length, calling_ply, allserver)
208210
return
209211
end
@@ -308,7 +310,7 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
308310
UPDATE `tbl_mbsync`
309311
SET
310312
reason=?,
311-
length_unix=?,
313+
length_unix=(UNIX_TIMESTAMP() - date_unix) + ?,
312314
admin_id=(SELECT p_user_id FROM tbl_users WHERE steamid=? AND steamid64=?),
313315
server_group=(SELECT p_group_id FROM tbl_server_grp WHERE group_name=?)
314316
WHERE p_ID=?
@@ -1495,7 +1497,11 @@ MSync.modules[info.ModuleIdentifier].hooks = function()
14951497
if banData.unban == 0 then
14961498
ban.length = 0
14971499
else
1498-
ban.length = (banData.unban-os.time()) / 60
1500+
if banData.modified_time then
1501+
ban.length = (banData.unban-banData.modified_time) / 60
1502+
else
1503+
ban.length = (banData.unban-banData.time) / 60
1504+
end
14991505
end
15001506

15011507
if not banData.reason then

0 commit comments

Comments
 (0)