Loading lua/msync/client_gui/modules/cl_mbsync.lua +115 −120 Original line number Diff line number Diff line Loading @@ -30,17 +30,7 @@ MSync.modules[info.ModuleIdentifier].info = info ]] MSync.modules[info.ModuleIdentifier].init = function() MSync.modules[info.ModuleIdentifier].banPanel = function() local panel = vgui.Create( "DFrame" ) panel:SetSize( 800, 500 ) panel:SetTitle( "MBSync - Ban User " ) panel:Center() panel:MakePopup() end end MSync.modules[info.ModuleIdentifier].banPanel = function() MSync.modules[info.ModuleIdentifier].banPanel = function( tbl ) local panel = vgui.Create( "DFrame" ) panel:SetSize( 350, 500 ) panel:SetTitle( "MBSync - Ban User " ) Loading Loading @@ -144,10 +134,17 @@ MSync.modules[info.ModuleIdentifier].banPanel = function() steamid_textentry:SetText(pnl:GetColumnText( 2 )) end if tbl then for k,v in pairs(tbl) do ban_table:AddLine( v.name, v.steamid, v.steamid64 ) end end ban_table:AddLine( "[ApDev] Rainbow Dash", "STEAM_0:0:0", "76000000000" ) end MSync.modules[info.ModuleIdentifier].banPanel() end --[[ Define the admin panel for the settings ]] Loading Loading @@ -923,6 +920,14 @@ MSync.modules[info.ModuleIdentifier].net = function() net.Receive( "msync."..(info.ModuleIdentifier)..".banid", function( len, ply ) chat.AddText( Color( 237, 135, 26 ), "[MBSync] ", Color( 255, 255, 255), net.ReadString()) end ) --[[ Description: Net Receiver - Gets called when the client entered '!mban' Returns: nothing ]] net.Receive( "msync."..(info.ModuleIdentifier)..".openBanGUI", function( len, ply ) MSync.modules[info.ModuleIdentifier].banPanel(net.ReadTable()) end ) end --[[ Loading @@ -936,17 +941,7 @@ end Define hooks your module is listening on e.g. PlayerDisconnect ]] MSync.modules[info.ModuleIdentifier].hooks = function() gameevent.Listen( "player_disconnect" ) hook.Add( "player_disconnect", "player_disconnect_example", function( data ) local name = data.name // Same as Player:Nick() local steamid = data.networkid // Same as Player:SteamID() local id = data.userid // Same as Player:UserID() local bot = data.bot // Same as Player:IsBot() local reason = data.reason // Text reason for disconnected such as "Kicked by console!", "Timed out!", etc... // Player has disconnected - this is more reliable than PlayerDisconnect end ) -- end Loading lua/msync/server/modules/sv_mbsync.lua +48 −8 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ local info = { ]] MSync.modules[info.ModuleIdentifier] = MSync.modules[info.ModuleIdentifier] or {} MSync.modules[info.ModuleIdentifier].info = info MSync.modules[info.ModuleIdentifier].recentDisconnects = MSync.modules[info.ModuleIdentifier].recentDisconnects or {} --[[ Define mysql table and additional functions that are later used Loading Loading @@ -599,7 +600,7 @@ MSync.modules[info.ModuleIdentifier].net = function() end ) --[[ Description: Net Receiver - Gets called when the client requests the settings table Description: Net Receiver - Gets called when the client wants to open the ban gui Returns: nothing ]] util.AddNetworkString("msync."..info.ModuleIdentifier..".sendSettings") Loading @@ -610,6 +611,34 @@ MSync.modules[info.ModuleIdentifier].net = function() MSync.modules[info.ModuleIdentifier].saveSettings() end ) --[[ Description: Function to send the 10 last disconnects to a player Arguments: player [player] - the player that requests the data Returns: nothing ]] util.AddNetworkString("msync."..info.ModuleIdentifier..".openBanGUI") MSync.modules[info.ModuleIdentifier].openBanGUI = function(ply) local tableLength = #MSync.modules[info.ModuleIdentifier].recentDisconnects local disconnectTable = {} if not tableLength == 0 then for i = 0, 9, 1 do if MSync.modules[info.ModuleIdentifier].recentDisconnects[tableLength-i] then disconnectTable[i] = MSync.modules[info.ModuleIdentifier].recentDisconnects[tableLength-i] else break end end else disconnectTable = {} end net.Start("msync."..info.ModuleIdentifier..".openBanGUI") net.WriteTable(disconnectTable) net.Send(ply) end end --[[ Loading @@ -634,8 +663,8 @@ MSync.modules[info.ModuleIdentifier].ulx = function() if not calling_ply:query("msync."..(info.ModuleIdentifier)..".banPlayer") then return end; if not IsValid(calling_ply) then return end; if not target_ply then -- Open GUI if calling_ply == target_ply then MSync.modules[info.ModuleIdentifier].openBanGUI(calling_ply) else if not IsValid(target_ply) then return end Loading Loading @@ -804,11 +833,11 @@ MSync.modules[info.ModuleIdentifier].ulx = function() Arguments: none ]] MSync.modules[info.ModuleIdentifier].Chat.openBanTable = function(calling_ply) MSync.modules[info.ModuleIdentifier].openBanTable = function(calling_ply) if not calling_ply:query("msync."..(info.ModuleIdentifier)..".openBanTable") then return end; -- Open Ban Table end local BanPlayer = ulx.command( "MSync", "msync."..(info.ModuleIdentifier)..".openBanTable", MSync.modules[info.ModuleIdentifier].openBanGUI, "!mbsync" ) local BanPlayer = ulx.command( "MSync", "msync."..(info.ModuleIdentifier)..".openBanTable", MSync.modules[info.ModuleIdentifier].openBanTable, "!mbsync" ) BanPlayer:defaultAccess( ULib.ACCESS_SUPERADMIN ) BanPlayer:help( "Opens MSync Settings." ) Loading @@ -830,7 +859,7 @@ MSync.modules[info.ModuleIdentifier].hooks = function() end) end) hook.Add("CheckPassword", "MBSyncBanCheck", function( steamid64 ) hook.Add("CheckPassword", "msync."..(info.ModuleIdentifier)..".banCheck", function( steamid64 ) if MSync.modules[info.ModuleIdentifier].banTable[steamid64] then local ban = MSync.modules[info.ModuleIdentifier].banTable[steamid64] Loading Loading @@ -868,6 +897,17 @@ MSync.modules[info.ModuleIdentifier].hooks = function() return end end) hook.Add("PlayerDisconnected", "msync."..(info.ModuleIdentifier)..".saveDisconnects", function( ply ) local tableLength = #MSync.modules[info.ModuleIdentifier].recentDisconnects local data = { name = ply:Name(), steamid = ply:SteamID(), steamid64 = ply:SteamID64() } MSync.modules[info.ModuleIdentifier].recentDisconnects[tableLength] = data end) end --[[ Loading Loading
lua/msync/client_gui/modules/cl_mbsync.lua +115 −120 Original line number Diff line number Diff line Loading @@ -30,17 +30,7 @@ MSync.modules[info.ModuleIdentifier].info = info ]] MSync.modules[info.ModuleIdentifier].init = function() MSync.modules[info.ModuleIdentifier].banPanel = function() local panel = vgui.Create( "DFrame" ) panel:SetSize( 800, 500 ) panel:SetTitle( "MBSync - Ban User " ) panel:Center() panel:MakePopup() end end MSync.modules[info.ModuleIdentifier].banPanel = function() MSync.modules[info.ModuleIdentifier].banPanel = function( tbl ) local panel = vgui.Create( "DFrame" ) panel:SetSize( 350, 500 ) panel:SetTitle( "MBSync - Ban User " ) Loading Loading @@ -144,10 +134,17 @@ MSync.modules[info.ModuleIdentifier].banPanel = function() steamid_textentry:SetText(pnl:GetColumnText( 2 )) end if tbl then for k,v in pairs(tbl) do ban_table:AddLine( v.name, v.steamid, v.steamid64 ) end end ban_table:AddLine( "[ApDev] Rainbow Dash", "STEAM_0:0:0", "76000000000" ) end MSync.modules[info.ModuleIdentifier].banPanel() end --[[ Define the admin panel for the settings ]] Loading Loading @@ -923,6 +920,14 @@ MSync.modules[info.ModuleIdentifier].net = function() net.Receive( "msync."..(info.ModuleIdentifier)..".banid", function( len, ply ) chat.AddText( Color( 237, 135, 26 ), "[MBSync] ", Color( 255, 255, 255), net.ReadString()) end ) --[[ Description: Net Receiver - Gets called when the client entered '!mban' Returns: nothing ]] net.Receive( "msync."..(info.ModuleIdentifier)..".openBanGUI", function( len, ply ) MSync.modules[info.ModuleIdentifier].banPanel(net.ReadTable()) end ) end --[[ Loading @@ -936,17 +941,7 @@ end Define hooks your module is listening on e.g. PlayerDisconnect ]] MSync.modules[info.ModuleIdentifier].hooks = function() gameevent.Listen( "player_disconnect" ) hook.Add( "player_disconnect", "player_disconnect_example", function( data ) local name = data.name // Same as Player:Nick() local steamid = data.networkid // Same as Player:SteamID() local id = data.userid // Same as Player:UserID() local bot = data.bot // Same as Player:IsBot() local reason = data.reason // Text reason for disconnected such as "Kicked by console!", "Timed out!", etc... // Player has disconnected - this is more reliable than PlayerDisconnect end ) -- end Loading
lua/msync/server/modules/sv_mbsync.lua +48 −8 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ local info = { ]] MSync.modules[info.ModuleIdentifier] = MSync.modules[info.ModuleIdentifier] or {} MSync.modules[info.ModuleIdentifier].info = info MSync.modules[info.ModuleIdentifier].recentDisconnects = MSync.modules[info.ModuleIdentifier].recentDisconnects or {} --[[ Define mysql table and additional functions that are later used Loading Loading @@ -599,7 +600,7 @@ MSync.modules[info.ModuleIdentifier].net = function() end ) --[[ Description: Net Receiver - Gets called when the client requests the settings table Description: Net Receiver - Gets called when the client wants to open the ban gui Returns: nothing ]] util.AddNetworkString("msync."..info.ModuleIdentifier..".sendSettings") Loading @@ -610,6 +611,34 @@ MSync.modules[info.ModuleIdentifier].net = function() MSync.modules[info.ModuleIdentifier].saveSettings() end ) --[[ Description: Function to send the 10 last disconnects to a player Arguments: player [player] - the player that requests the data Returns: nothing ]] util.AddNetworkString("msync."..info.ModuleIdentifier..".openBanGUI") MSync.modules[info.ModuleIdentifier].openBanGUI = function(ply) local tableLength = #MSync.modules[info.ModuleIdentifier].recentDisconnects local disconnectTable = {} if not tableLength == 0 then for i = 0, 9, 1 do if MSync.modules[info.ModuleIdentifier].recentDisconnects[tableLength-i] then disconnectTable[i] = MSync.modules[info.ModuleIdentifier].recentDisconnects[tableLength-i] else break end end else disconnectTable = {} end net.Start("msync."..info.ModuleIdentifier..".openBanGUI") net.WriteTable(disconnectTable) net.Send(ply) end end --[[ Loading @@ -634,8 +663,8 @@ MSync.modules[info.ModuleIdentifier].ulx = function() if not calling_ply:query("msync."..(info.ModuleIdentifier)..".banPlayer") then return end; if not IsValid(calling_ply) then return end; if not target_ply then -- Open GUI if calling_ply == target_ply then MSync.modules[info.ModuleIdentifier].openBanGUI(calling_ply) else if not IsValid(target_ply) then return end Loading Loading @@ -804,11 +833,11 @@ MSync.modules[info.ModuleIdentifier].ulx = function() Arguments: none ]] MSync.modules[info.ModuleIdentifier].Chat.openBanTable = function(calling_ply) MSync.modules[info.ModuleIdentifier].openBanTable = function(calling_ply) if not calling_ply:query("msync."..(info.ModuleIdentifier)..".openBanTable") then return end; -- Open Ban Table end local BanPlayer = ulx.command( "MSync", "msync."..(info.ModuleIdentifier)..".openBanTable", MSync.modules[info.ModuleIdentifier].openBanGUI, "!mbsync" ) local BanPlayer = ulx.command( "MSync", "msync."..(info.ModuleIdentifier)..".openBanTable", MSync.modules[info.ModuleIdentifier].openBanTable, "!mbsync" ) BanPlayer:defaultAccess( ULib.ACCESS_SUPERADMIN ) BanPlayer:help( "Opens MSync Settings." ) Loading @@ -830,7 +859,7 @@ MSync.modules[info.ModuleIdentifier].hooks = function() end) end) hook.Add("CheckPassword", "MBSyncBanCheck", function( steamid64 ) hook.Add("CheckPassword", "msync."..(info.ModuleIdentifier)..".banCheck", function( steamid64 ) if MSync.modules[info.ModuleIdentifier].banTable[steamid64] then local ban = MSync.modules[info.ModuleIdentifier].banTable[steamid64] Loading Loading @@ -868,6 +897,17 @@ MSync.modules[info.ModuleIdentifier].hooks = function() return end end) hook.Add("PlayerDisconnected", "msync."..(info.ModuleIdentifier)..".saveDisconnects", function( ply ) local tableLength = #MSync.modules[info.ModuleIdentifier].recentDisconnects local data = { name = ply:Name(), steamid = ply:SteamID(), steamid64 = ply:SteamID64() } MSync.modules[info.ModuleIdentifier].recentDisconnects[tableLength] = data end) end --[[ Loading