Skip to content

Commit 7bd9a0f

Browse files
CHEESE UPDATE
Fixet lots of stuff - Netting done - Updated DB Structure - Tested Functionality UPDATE: CHEESE_0.1.0 Partially Working Version
1 parent c9726b6 commit 7bd9a0f

File tree

15 files changed

+170
-57
lines changed

15 files changed

+170
-57
lines changed

database.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ CREATE TABLE IF NOT EXISTS `tbl_users` (
2424
`steamid` VARCHAR(20) NOT NULL,
2525
`steamid64` VARCHAR(17) NOT NULL,
2626
`nickname` VARCHAR(30) NOT NULL,
27-
`joined` DATETIME NOT NULL
27+
`joined` DATETIME NOT NULL,
28+
UNIQUE INDEX `steamid_UNIQUE` (`steamid`),
29+
UNIQUE INDEX `steamid64_UNIQUE` (`steamid64`)
2830
);
2931

3032
CREATE TABLE IF NOT EXISTS `tbl_mbsync` (

msync/client_gui/cl_admin_gui.lua

Lines changed: 78 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ function MSync.AdminPanel.InitMySQL( sheet )
1818
mysqlip:SetPos( 25, 50 )
1919
mysqlip:SetSize( 150, 20 )
2020
mysqlip:SetText( "127.0.0.1" )
21-
mysqlip.OnEnter = function( self )
22-
chat.AddText( self:GetValue() )
23-
end
2421

2522
local mysqlport_text = vgui.Create( "DLabel", pnl )
2623
mysqlport_text:SetPos( 25, 75 )
@@ -31,9 +28,6 @@ function MSync.AdminPanel.InitMySQL( sheet )
3128
mysqlport:SetPos( 25, 95 )
3229
mysqlport:SetSize( 150, 20 )
3330
mysqlport:SetText( "3306" )
34-
mysqlport.OnEnter = function( self )
35-
chat.AddText( self:GetValue() )
36-
end
3731

3832
local mysqldb_text = vgui.Create( "DLabel", pnl )
3933
mysqldb_text:SetPos( 25, 120 )
@@ -44,9 +38,6 @@ function MSync.AdminPanel.InitMySQL( sheet )
4438
mysqldb:SetPos( 25, 140 )
4539
mysqldb:SetSize( 150, 20 )
4640
mysqldb:SetText( "MSync" )
47-
mysqldb.OnEnter = function( self )
48-
chat.AddText( self:GetValue() )
49-
end
5041

5142
local mysqluser_text = vgui.Create( "DLabel", pnl )
5243
mysqluser_text:SetPos( 25, 165 )
@@ -57,9 +48,6 @@ function MSync.AdminPanel.InitMySQL( sheet )
5748
mysqluser:SetPos( 25, 185 )
5849
mysqluser:SetSize( 150, 20 )
5950
mysqluser:SetText( "root" )
60-
mysqluser.OnEnter = function( self )
61-
chat.AddText( self:GetValue() )
62-
end
6351

6452
local mysqlpassword_text = vgui.Create( "DLabel", pnl )
6553
mysqlpassword_text:SetPos( 25, 210 )
@@ -70,48 +58,101 @@ function MSync.AdminPanel.InitMySQL( sheet )
7058
mysqlpassword:SetPos( 25, 230 )
7159
mysqlpassword:SetSize( 150, 20 )
7260
mysqlpassword:SetText( "*****" )
73-
mysqlpassword.OnEnter = function( self )
74-
chat.AddText( self:GetValue() )
75-
end
61+
62+
local title_info = vgui.Create( "DLabel", pnl )
63+
title_info:SetPos( 200, 25 )
64+
title_info:SetColor( Color( 0, 0, 0 ) )
65+
title_info:SetSize(400, 15)
66+
title_info:SetText( "--Information--" )
67+
68+
local info = vgui.Create( "DLabel", pnl )
69+
info:SetPos( 200, 30 )
70+
info:SetColor( Color( 0, 0, 0 ) )
71+
info:SetSize(400, 200)
72+
info:SetText( [[
73+
Support: https://www.Aperture-Development.de
74+
GitHub: https://github.com/Aperture-Development/MSync-2
75+
LICENCE: To know what you are allowed to do and what not,
76+
read the LICENCE file in the root directory of the addon.
77+
If there is no file, the Licence by-nc-sa 4.0 International applies.
78+
79+
Developer: This Addon was created by Aperture Development.
80+
Copyright 2018 - Aperture Development
81+
]] )
82+
83+
local dbstatus = vgui.Create( "DLabel", pnl )
84+
dbstatus:SetPos( 200, 210 )
85+
dbstatus:SetColor( Color( 0, 0, 0 ) )
86+
dbstatus:SetSize(400, 15)
87+
dbstatus:SetText( "DB Connection status: -Not Implemented-" )
7688

7789
local save_button = vgui.Create( "DButton", pnl )
7890
save_button:SetText( "Save Settings" )
7991
save_button:SetPos( 25, 290 )
8092
save_button:SetSize( 130, 30 )
81-
save_button.DoClick = function() end
93+
save_button.DoClick = function()
94+
MSync.settings.mysql.host = mysqlip:GetValue()
95+
MSync.settings.mysql.port = mysqlport:GetValue()
96+
MSync.settings.mysql.database = mysqldb:GetValue()
97+
MSync.settings.mysql.username = mysqluser:GetValue()
98+
MSync.settings.mysql.password = mysqlpassword:GetValue()
99+
MSync.net.sendSettings(MSync.settings)
100+
end
82101

83102
local saveconnect_button = vgui.Create( "DButton", pnl )
84103
saveconnect_button:SetText( "Save and Connect" )
85104
saveconnect_button:SetPos( 155, 290 )
86105
saveconnect_button:SetSize( 130, 30 )
87-
saveconnect_button.DoClick = function() end
106+
saveconnect_button.DoClick = function()
107+
MSync.settings.mysql.host = mysqlip:GetValue()
108+
MSync.settings.mysql.port = mysqlport:GetValue()
109+
MSync.settings.mysql.database = mysqldb:GetValue()
110+
MSync.settings.mysql.username = mysqluser:GetValue()
111+
MSync.settings.mysql.password = mysqlpassword:GetValue()
112+
MSync.net.sendSettings(MSync.settings)
113+
MSync.net.connectDB()
114+
end
88115

89116
local connect_button = vgui.Create( "DButton", pnl )
90117
connect_button:SetText( "Connect" )
91118
connect_button:SetPos( 285, 290 )
92119
connect_button:SetSize( 130, 30 )
93-
connect_button.DoClick = function() end
120+
connect_button.DoClick = function()
121+
MSync.net.connectDB()
122+
end
94123

95124
local reset_button = vgui.Create( "DButton", pnl )
96125
reset_button:SetText( "Reset Settings" )
97126
reset_button:SetPos( 415, 290 )
98127
reset_button:SetSize( 130, 30 )
99-
reset_button.DoClick = function() end
128+
reset_button.DoClick = function()
129+
mysqlip:SetText("127.0.0.1")
130+
mysqlport:SetText("3306")
131+
mysqldb:SetText("msync")
132+
mysqluser:SetText("root")
133+
mysqlpassword:SetText("****")
134+
MSync.settings.mysql.host = mysqlip:GetValue()
135+
MSync.settings.mysql.port = mysqlport:GetValue()
136+
MSync.settings.mysql.database = mysqldb:GetValue()
137+
MSync.settings.mysql.username = mysqluser:GetValue()
138+
MSync.settings.mysql.password = ""
139+
MSync.net.sendSettings(MSync.settings)
140+
end
100141

101142
if not MSync.settings == nil then
102143
mysqlip:SetText(MSync.settings.mysql.host)
103144
mysqlport:SetText(MSync.settings.mysql.port)
104145
mysqldb:SetText(MSync.settings.mysql.database)
105146
mysqluser:SetText(MSync.settings.mysql.username)
106147
else
107-
timer.Create("msync.t.checkForSettings", 1, 0, function()
148+
timer.Create("msync.t.checkForSettings", 0.5, 0, function()
108149
if not MSync.settings or not MSync.settings.mysql then return end;
109150

110-
timer.Remove("msync.t.checkForSettings")
111151
mysqlip:SetText(MSync.settings.mysql.host)
112152
mysqlport:SetText(MSync.settings.mysql.port)
113153
mysqldb:SetText(MSync.settings.mysql.database)
114154
mysqluser:SetText(MSync.settings.mysql.username)
155+
timer.Remove("msync.t.checkForSettings")
115156
end)
116157
end
117158

@@ -134,16 +175,26 @@ function MSync.AdminPanel.InitModules( sheet )
134175
ModuleList:AddColumn( "Enabled" )
135176

136177
timer.Create("msync.t.checkForServerModules", 1, 0, function()
137-
138178
if not MSync.serverModules then return end;
139179

140-
timer.Remove("msync.t.checkForServerModules")
141-
142180
for k,v in pairs(MSync.serverModules) do
143-
ModuleList:AddItem(v["Name"], v["ModuleIdentifier"], v["state"])
181+
ModuleList:AddLine(v["Name"], v["ModuleIdentifier"], v["state"])
144182
end
183+
timer.Remove("msync.t.checkForServerModules")
145184
end)
146-
185+
ModuleList.OnRowRightClick = function(panel, lineID, line)
186+
local ident = line:GetValue(2)
187+
local cursor_x, cursor_y = ModuleList:CursorPos()
188+
local DMenu = vgui.Create("DMenu", ModuleList)
189+
DMenu:SetPos(cursor_x, cursor_y)
190+
DMenu:AddOption(MSync.serverModules[ident].Description)
191+
DMenu:AddSpacer()
192+
DMenu:AddOption("Enable")
193+
DMenu:AddOption("Disable")
194+
DMenu.OptionSelected = function(menu,optPnl,optStr)
195+
MSync.net.toggleModule(ident, optStr)
196+
end
197+
end
147198
return pnl
148199
end
149200

@@ -178,6 +229,7 @@ function MSync.AdminPanel.InitPanel()
178229

179230
local panel = vgui.Create( "DFrame" )
180231
panel:SetSize( 600, 400 )
232+
panel:SetTitle( "MSync Admin Menu" )
181233
panel:Center()
182234
panel:MakePopup()
183235

msync/client_gui/cl_net.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ function MSync.net.getModules()
1919
net.SendToServer()
2020
end
2121

22+
--[[
23+
Description: function to toggle a module
24+
Returns: nothing
25+
]]
26+
function MSync.net.toggleModule(ident, state)
27+
net.Start("msync.toggleModule")
28+
net.WriteString(ident)
29+
net.WriteString(state)
30+
net.SendToServer()
31+
end
32+
2233
--[[
2334
Description: function to send settngs to the server
2435
Returns: nothing
@@ -29,6 +40,15 @@ function MSync.net.sendSettings(table)
2940
net.SendToServer()
3041
end
3142

43+
--[[
44+
Description: function to connect to the database server
45+
Returns: nothing
46+
]]
47+
function MSync.net.connectDB()
48+
net.Start("msync.connectDB")
49+
net.SendToServer()
50+
end
51+
3252
--[[
3353
Description: Net Receiver - Gets called when the server sends a table to the client
3454
Returns: nothing

msync/server/modules/sv_mbsync.lua

Whitespace-only changes.

msync/server/modules/sv_mrs.lua

Whitespace-only changes.

msync/server/modules/sv_mrsync.lua

Whitespace-only changes.

msync/server/modules/sv_musync.lua

Whitespace-only changes.

msync/server/modules/sv_mws.lua

Whitespace-only changes.

msync/server/modules/sv_samplemodule.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
MSync = Msync or {}
1+
MSync = MSync or {}
22
MSync.modules = MSync.modules or {}
33
MSync.modules.SampleModule = MSync.modules.SampleModule or {}
44
--[[
@@ -22,7 +22,7 @@ MSync.modules.SampleModule.info = {
2222
--[[
2323
Define mysql table and additional functions that are later used
2424
]]
25-
function MSync.Modules.SampleModule.init( transaction )
25+
function MSync.modules.SampleModule.init( transaction )
2626
transaction:addQuery( [[
2727
CREATE TABLE IF NOT EXISTS `tbl_SampleModule` (
2828
SampleData INT
@@ -38,7 +38,7 @@ end
3838
--[[
3939
Define net receivers and util.AddNetworkString
4040
]]
41-
function MSync.Modules.SampleModule.net()
41+
function MSync.modules.SampleModule.net()
4242
net.Receive( "my_message", function( len, pl )
4343
if ( IsValid( pl ) and pl:IsPlayer() ) then
4444
print( "Message from " .. pl:Nick() .. " received. Its length is " .. len .. "." )
@@ -51,14 +51,14 @@ end
5151
--[[
5252
Define ulx Commands and overwrite common ulx functions (module does not get loaded until ulx has fully been loaded)
5353
]]
54-
function MSync.Modules.SampleModule.ulx()
54+
function MSync.modules.SampleModule.ulx()
5555

5656
end
5757

5858
--[[
5959
Define hooks your module is listening on e.g. PlayerDisconnect
6060
]]
61-
function MSync.Modules.SampleModule.hooks()
61+
function MSync.modules.SampleModule.hooks()
6262
hook.Add("initialize", "msync_sampleModule_init", function()
6363

6464
end)

msync/server/sv_hooks.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
--[[
22
Description: hook to initialize MSync 2
33
Returns: nothing
4-
]]
5-
--[[
4+
5+
Somehow the hook never gets called and I can't fix that.
6+
]
67
hook.Add( "Initialize", "msync.initScript", function()
78
MSync.func.loadSettings()
89
910
--[[
1011
Description: timer to prevent loading before ULX
1112
Returns: nothing
12-
]
13+
]
1314
timer.Create("msync.t.checkForULXandULib", 5, 0, function()
14-
if not ULX and ULib then return end;
15+
if not ULX or not ULib then return end;
1516
1617
timer.Remove("msync.t.checkForULXandULib")
1718
MSync.ulx.createPermissions()

0 commit comments

Comments
 (0)