Commit 67cc99e5 authored by Maximilian Grüttemeier's avatar Maximilian Grüttemeier
Browse files

Messages

- Added messages on successfull MBSync Action
parent b190d1ae
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1161,7 +1161,7 @@ MSync.modules[info.ModuleIdentifier].net = function()
        Description: Net Receiver - Gets called when the server wants to print something to the user chat
        Returns: nothing
    ]]
    net.Receive( "msync."..(info.ModuleIdentifier)..".banid", function( len, ply )
    net.Receive( "msync."..(info.ModuleIdentifier)..".sendMessage", function( len, ply )
        chat.AddText( Color( 237, 135, 26 ), "[MBSync] ", Color( 255, 255, 255), net.ReadString())
    end )

+41 −7
Original line number Diff line number Diff line
@@ -83,9 +83,6 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
                time = os.time()
            }

            PrintTable(banData)
            PrintTable(data)

            ply:Kick(ULib.getBanMessage( ply:SteamID(), banData))
            MSync.modules[info.ModuleIdentifier].getActiveBans()
            MSync.modules[info.ModuleIdentifier].msg(calling_ply, "Banned "..ply:Nick().." for "..ULib.secondsToStringTime(length).." with reason "..reason)
@@ -133,6 +130,23 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
            banUserIdQ:setString(8, "allservers")
        end

        banUserIdQ.onSuccess = function( q, data )
            -- Notify the user about the ban and add it to ULib to prevent data loss on Addon Remove
            -- Also, kick the user from the server
            local banData = {
                admin = calling_ply:Nick(),
                reason = reason,
                unban = os.time()+(length*60),
                time = os.time()
            }

            if not player.GetBySteamID(userid) then return end

            player.GetBySteamID(userid):Kick(ULib.getBanMessage( userid, banData))
            MSync.modules[info.ModuleIdentifier].getActiveBans()
            MSync.modules[info.ModuleIdentifier].msg(calling_ply, "Banned "..userid.." for "..ULib.secondsToStringTime(length).." with reason "..reason)
        end

        banUserIdQ.onError = function( q, err, sql )
            print("------------------------------------")
            print("[MBSync] SQL Error!")
@@ -173,6 +187,11 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
        end
        editBanQ:setString(6, banId)

        editBanQ.onSuccess = function( q, data )
            MSync.modules[info.ModuleIdentifier].getActiveBans()
            MSync.modules[info.ModuleIdentifier].msg(calling_ply, "Edited ban with id "..banId.." with length "..length.." with reason "..reason)
        end

        editBanQ.onError = function( q, err, sql )
            print("------------------------------------")
            print("[MBSync] SQL Error!")
@@ -202,6 +221,11 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
        unBanUserIdQ:setString(2, calling_ply:SteamID64())
        unBanUserIdQ:setString(3, banId)

        unBanUserIdQ.onSuccess = function( q, data )
            MSync.modules[info.ModuleIdentifier].getActiveBans()
            MSync.modules[info.ModuleIdentifier].msg(calling_ply, "Removed ban with id "..banId)
        end

        unBanUserIdQ.onError = function( q, err, sql )
            print("------------------------------------")
            print("[MBSync] SQL Error!")
@@ -236,6 +260,11 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
        unBanUserQ:setString(4, ply_steamid)
        unBanUserQ:setString(5, MSync.settings.data.serverGroup)

        unBanUserQ.onSuccess = function( q, data )
            MSync.modules[info.ModuleIdentifier].getActiveBans()
            MSync.modules[info.ModuleIdentifier].msg(calling_ply, "Unbanned "..ply_steamid)
        end

        unBanUserQ.onError = function( q, err, sql )
            print("------------------------------------")
            print("[MBSync] SQL Error!")
@@ -501,11 +530,16 @@ MSync.modules[info.ModuleIdentifier].net = function()
        Returns: nothing
    ]]  
    util.AddNetworkString("msync."..(info.ModuleIdentifier)..".sendMessage")
    MSync.modules[info.ModuleIdentifier].msg = function(ply, text)
    MSync.modules[info.ModuleIdentifier].msg = function(ply, content, type)
        if not type then type = 0 end
        -- Basic message
        if type == 0 then
            net.Start("msync."..(info.ModuleIdentifier)..".sendMessage")
            net.WriteString(text)
                net.WriteFloat(type)
                net.WriteString(content)
            net.Send(ply)
        end
    end

    --[[
        Description: Function to send the ban list to a player