Skip to content

Commit 31143e9

Browse files
Bugfix
- Fixed that messages could not be delivered to players when the function only gets a steamid - Fixed a bug that caused the unban function not to work
1 parent 5205b0e commit 31143e9

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

lua/msync/server/modules/sv_mbsync.lua

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
197197
);
198198
]] )
199199
local timestamp = os.time()
200-
print(timestamp)
200+
print(reason)
201201
banUserIdQ:setString(1, userid)
202202
banUserIdQ:setString(2, userid)
203203
banUserIdQ:setString(3, calling_ply)
@@ -214,7 +214,6 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
214214
banUserIdQ.onSuccess = function( q, data )
215215
-- Notify the user about the ban and add it to ULib to prevent data loss on Addon Remove
216216
-- Also, kick the user from the server
217-
print(q)
218217
if calling_ply == "STEAM_0:0:0" then
219218
adminNick = "(CONSOLE)"
220219
else
@@ -239,13 +238,13 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
239238
else
240239
msgReason = reason
241240
end
241+
MSync.modules[info.ModuleIdentifier].getActiveBans()
242242

243243
MSync.modules[info.ModuleIdentifier].msg(calling_ply, "Banned "..userid.." for "..msgLength.." with reason "..msgReason)
244244

245245
if not player.GetBySteamID(userid) then return end
246246

247247
player.GetBySteamID(userid):Kick("\n"..ULib.getBanMessage( userid, banData))
248-
MSync.modules[info.ModuleIdentifier].getActiveBans()
249248
end
250249

251250
banUserIdQ.onError = function( q, err, sql )
@@ -354,14 +353,15 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
354353
WHERE
355354
user_id=(SELECT p_user_id FROM tbl_users WHERE steamid=? OR steamid64=?) AND
356355
server_group=(SELECT p_group_id FROM tbl_server_grp WHERE group_name=?) AND
357-
(date_unix + length_unix) >= ?
356+
((date_unix + length_unix) >= ? OR length_unix = 0) AND
357+
ban_lifted IS NULL
358358
]] )
359359
unBanUserQ:setString(1, calling_ply)
360360
unBanUserQ:setString(2, util.SteamIDTo64(calling_ply))
361361
unBanUserQ:setString(3, ply_steamid)
362362
unBanUserQ:setString(4, ply_steamid)
363363
unBanUserQ:setString(5, MSync.settings.data.serverGroup)
364-
unBanUserQ:setString(6, os.time())
364+
unBanUserQ:setNumber(6, os.time())
365365

366366
unBanUserQ.onSuccess = function( q, data )
367367
MSync.modules[info.ModuleIdentifier].getActiveBans()
@@ -528,7 +528,6 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
528528
getActiveBansQ.onSuccess = function( q, data )
529529

530530
local banTable = {}
531-
PrintTable(data)
532531
print("[MBSync] Recieved ban data")
533532
for k,v in pairs(data) do
534533
banTable[v["steamid64"]] = {
@@ -616,7 +615,7 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
616615
)
617616
]] )
618617
exportActiveBans:setNumber(1, os.time())
619-
exportActiveBans:setString(8, MSync.settings.data.serverGroup)
618+
exportActiveBans:setString(2, MSync.settings.data.serverGroup)
620619

621620
exportActiveBans.onSuccess = function( q, data )
622621

@@ -722,6 +721,10 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
722721
Load settings when module finished loading
723722
]]
724723
MSync.modules[info.ModuleIdentifier].loadSettings()
724+
725+
if not MSync.modules[info.ModuleIdentifier].banTable then
726+
MSync.modules[info.ModuleIdentifier].getActiveBans()
727+
end
725728
end
726729

727730
--[[
@@ -737,15 +740,19 @@ MSync.modules[info.ModuleIdentifier].net = function()
737740
Returns: nothing
738741
]]
739742
util.AddNetworkString("msync."..info.ModuleIdentifier..".sendMessage")
740-
MSync.modules[info.ModuleIdentifier].msg = function(ply, content, type)
743+
MSync.modules[info.ModuleIdentifier].msg = function(ply, content, msgType)
744+
if type(ply) == "string" and not ply == "STEAM_0:0:0" then
745+
ply = player.GetBySteamID( ply )
746+
end
747+
741748
if not ply or ply == "STEAM_0:0:0" then
742749
print("[MBSync] "..content)
743750
else
744-
if not type then type = 0 end
751+
if not msgType then msgType = 0 end
745752
-- Basic message
746-
if type == 0 then
753+
if msgType == 0 then
747754
net.Start("msync."..info.ModuleIdentifier..".sendMessage")
748-
net.WriteFloat(type)
755+
net.WriteFloat(msgType)
749756
net.WriteString(content)
750757
net.Send(ply)
751758
end
@@ -1082,7 +1089,7 @@ MSync.modules[info.ModuleIdentifier].ulx = function()
10821089
end
10831090
end
10841091

1085-
if not reason then reason = "No reason given" end
1092+
reason = reason or "No reason given"
10861093

10871094
--[[
10881095
Run ban function with given functions

0 commit comments

Comments
 (0)