Skip to content

Commit a593842

Browse files
@captain1242@captain1242
authored andcommitted
Added Function comments
Update: EGG_0.0.3
1 parent 947e883 commit a593842

File tree

9 files changed

+162
-27
lines changed

9 files changed

+162
-27
lines changed

msync/client_gui/cl_admin_gui.lua

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
AddCSLuaFile()
2-
31
MSync = MSync or {}
42
MSync.AdminPanel = MSync.AdminPanel or {}
53

4+
--[[
5+
Description: MySQL settings panel
6+
Arguments: parent sheet
7+
Returns: panel
8+
]]
69
function MSync.AdminPanel.InitMySQL( sheet )
710
local pnl = vgui.Create( "DPanel", sheet )
811

@@ -112,6 +115,11 @@ function MSync.AdminPanel.InitMySQL( sheet )
112115
return pnl
113116
end
114117

118+
--[[
119+
Description: Module list panel
120+
Arguments: parent sheet
121+
Returns: panel
122+
]]
115123
function MSync.AdminPanel.InitModules( sheet )
116124
local pnl = vgui.Create( "DPanel", sheet )
117125

@@ -129,6 +137,11 @@ function MSync.AdminPanel.InitModules( sheet )
129137
return pnl
130138
end
131139

140+
--[[
141+
Description: Module settings panel
142+
Arguments: parent sheet
143+
Returns: panel
144+
]]
132145
function MSync.AdminPanel.InitModuleSettings( sheet )
133146
local pnl = vgui.Create( "DColumnSheet", sheet )
134147

@@ -140,7 +153,10 @@ function MSync.AdminPanel.InitModuleSettings( sheet )
140153
return pnl
141154
end
142155

143-
156+
--[[
157+
Description: MSync 2 panel
158+
Returns: nothing
159+
]]
144160
function MSync.AdminPanel.InitPanel()
145161

146162
--if not LocalPlayer():query("msync.admingui") then return false end;
@@ -162,4 +178,8 @@ function MSync.AdminPanel.InitPanel()
162178

163179
end
164180

181+
--[[
182+
Description: Debug function. Remove on command implementation.
183+
Returns: nothing
184+
]]
165185
MSync.AdminPanel.InitPanel()

msync/client_gui/cl_modules.lua

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@ MSync.mysql = MSync.mysql or {}
33
MSync.settings = MSync.settings or {}
44
MSync.modules = MSync.modules or {}
55

6+
--[[
7+
Description: loads the client side modules
8+
Returns: nothing
9+
]]
610
function MSync.loadModules()
711
for k, v in pairs(file.Find("msync/client_gui/modules/*.lua", "LUA")[1]) do
812
include("msync/client_gui/modules/"..v)
913
end
1014
end
1115

16+
--[[
17+
Description: initializes the client modules
18+
Returns: nothing
19+
]]
1220
function MSync.initModules()
1321

1422
for k,v in pairs(MSync.Modules) do
@@ -21,26 +29,20 @@ function MSync.initModules()
2129

2230
end
2331

32+
--[[
33+
Description: loads a single client side module
34+
Arguments: Module path
35+
Returns: nothing
36+
]]
2437
function MSync.loadModule(path)
2538
local initTransaction = MSync.DBServer:createTransaction()
2639
local info = include(path)
2740

28-
MSync.modules[info.ModuleIdentifier].init(initTransaction)
41+
MSync.modules[info.ModuleIdentifier].init()
2942
MSync.modules[info.ModuleIdentifier].net()
3043
MSync.modules[info.ModuleIdentifier].ulx()
3144
MSync.modules[info.ModuleIdentifier].hooks()
3245

3346
print("["..MSync.modules[info.Name].."] Module loaded")
3447

35-
function initTransaction.onSuccess()
36-
print("[MSync] Module query has been completed successfully")
37-
MSync.mysql[info.ModuleIdentifier].dbstatus = true
38-
end
39-
40-
function initTransaction.onError(tr, err)
41-
print("[MSync] There has been a error while loading the module querys.\nPlease inform the Developer and send him this:\n"..err)
42-
MSync.mysql[info.ModuleIdentifier].dbstatus = false
43-
end
44-
45-
initTransaction:start()
4648
end

msync/client_gui/cl_net.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,38 @@
11
MSync = MSync or {}
22
MSync.net = MSync.net or {}
33

4+
--[[
5+
Description: Function to get the server settings
6+
Returns: nothing
7+
]]
48
function MSync.net.getSettings()
59
net.Start("msync.getSettings")
610
net.SendToServer()
711
end
812

13+
--[[
14+
Description: function to get the modules
15+
Returns: nothing
16+
]]
917
function MSync.net.getModules()
1018
net.Start("msync.getModules")
1119
net.SendToServer()
1220
end
1321

22+
--[[
23+
Description: function to send settngs to the server
24+
Returns: nothing
25+
]]
1426
function MSync.net.sendSettings(table)
1527
net.Start("msync.sendSettings")
1628
net.WriteTable(table)
1729
net.SendToServer()
1830
end
1931

32+
--[[
33+
Description: Net Receiver - Gets called when the server sends a table to the client
34+
Returns: nothing
35+
]]
2036
net.Receive( "msync.sendTable", function( len, pl )
2137
local type = net.ReadString()
2238
local table = net.ReadTable()
@@ -25,6 +41,10 @@ net.Receive( "msync.sendTable", function( len, pl )
2541
elseif type == "modules" then MSync.serverModules = table end
2642
end )
2743

44+
--[[
45+
Description: Net Receiver - Gets called when the server sends a message to the client
46+
Returns: nothing
47+
]]
2848
net.Receive( "msync.sendMessage", function( len, pl )
2949
local state = net.ReadString()
3050

msync/server/sv_hooks.lua

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
1+
--[[
2+
Description: hook to initialize MSync 2
3+
Returns: nothing
4+
]]
15
hook.Add( "Initialize", "msync.initScript", function()
26
MSync.function.loadSettings()
3-
7+
8+
--[[
9+
Description: timer to prevent loading before ULX
10+
Returns: nothing
11+
]]
412
timer.Create("msync.checkForULXandULib", 5, 0, function()
513
if not ULX and ULib then return end;
614

715
MSync.mysql.initialize()
16+
MSync.ulx.createPermissions()
817
end)
918
end)
1019

20+
--[[
21+
Description: Creates a entry to the database for every player that joins.
22+
Returns: nothing
23+
]]
1124
hook.Add("PlayerInitialSpawn", "msync.createUser", function( ply )
1225
MSync.mysql.addUser(ply)
1326
end)

msync/server/sv_init.lua

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ MSync.modules = MSync.modules or {}
55
MSync.settings = MSync.settings or {}
66
MSync.function = MSync.function or {}
77

8-
8+
--[[
9+
Description: Function to load the server side files
10+
Returns: nothing
11+
]]
912
function MSync.function.loadServer()
1013

1114
include("/msync/server/sv_net.lua")
@@ -15,6 +18,10 @@ function MSync.function.loadServer()
1518

1619
end
1720

21+
--[[
22+
Description: Function to load the MSync settings file
23+
Returns: true
24+
]]
1825
function MSync.function.loadSettings()
1926
if not file.Exists("msync/settings.txt", "DATA") then
2027
MSync.settings.data = {
@@ -39,11 +46,19 @@ function MSync.function.loadSettings()
3946
return true
4047
end
4148

49+
--[[
50+
Description: Function to save the MSync settings to the settings file
51+
Returns: true if the settings file exists
52+
]]
4253
function MSync.function.saveSettings()
4354
file.Write("msync/settings.txt", util.TableToJSON(MSync.settings.data, true))
4455
return file.Exists("msync/settings.txt", "DATA")
4556
end
4657

58+
--[[
59+
Description: Function to get a table of the module informations
60+
Returns: table with Module informations
61+
]]
4762
function MSync.function.getModuleInfos()
4863
local infoTable = {}
4964

@@ -55,6 +70,11 @@ function MSync.function.getModuleInfos()
5570
return infoTable
5671
end
5772

73+
--[[
74+
Description: Function to return settings without the MySQL password
75+
We have decided that its better to Re-Enter the password always, and not be able to see the MySQL password client side
76+
Returns: safe settings table
77+
]]
5878
function MSync.function.getSafeSettings()
5979
local settings = MSync.settings.data
6080
settings.mysql.password = nil

msync/server/sv_modules.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@ MSync.mysql = MSync.mysql or {}
33
MSync.settings = MSync.settings or {}
44
MSync.modules = MSync.modules or {}
55

6+
--[[
7+
Description: Loads all server side modules
8+
Returns: nothing
9+
]]
610
function MSync.loadModules()
711
for k, v in pairs(file.Find("msync/server/modules/*.lua", "LUA")[1]) do
812
include("msync/server/modules/"..v)
913
end
1014
end
1115

16+
--[[
17+
Description: initializes all modules
18+
Returns: nothing
19+
]]
1220
function MSync.initModules()
1321
MSync.mysql.dbstatus = false
1422
if MSync.DBServer then
@@ -39,6 +47,11 @@ function MSync.initModules()
3947
end
4048
end
4149

50+
--[[
51+
Description: Loads single modules
52+
Arguments: path to module
53+
Returns: nothing
54+
]]
4255
function MSync.loadModule(path)
4356
local initTransaction = MSync.DBServer:createTransaction()
4457
local info = include(path)

msync/server/sv_mysql.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ MSync.mysql = MSync.mysql or {}
44
MSync.settings = MSync.settings or {}
55
MSync.function = MSync.function or {}
66

7+
--[[
8+
Description: initializes the MySQL part
9+
Returns: nothing
10+
]]
711
function MSync.mysql.initialize()
812
if (file.Exists( "bin/gmsv_mysqloo_linux.dll", "LUA" ) or file.Exists( "bin/gmsv_mysqloo_win32.dll", "LUA" )) and MSync.settings.data.mysql then
913
require("mysqloo")
@@ -73,6 +77,11 @@ function MSync.mysql.initialize()
7377
end
7478
end
7579

80+
--[[
81+
Description: Adds a user to the users table
82+
Arguments: player
83+
Returns: nothing
84+
]]
7685
function MSync.mysql.addUser(ply)
7786
if not MSync.DBServer then print("[MSync] No Database connected yet. Please connect to a Database to be able to create users."); return end;
7887

@@ -95,6 +104,10 @@ function MSync.mysql.addUser(ply)
95104
addUserQ:start()
96105
end
97106

107+
--[[
108+
Description: Function to print the MySQL informations to the console
109+
Returns: nothing
110+
]]
98111
function MSync.mysql.getInfo()
99112
print("--Database Server Information--")
100113
print("Version: "..MSync.DBServer:serverVersion())

msync/server/sv_net.lua

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
MSync = MSync or {}
22
MSync.net = MSync.net or {}
33

4+
--[[
5+
Description: Function to send a table to the client
6+
Arguments:
7+
player [player] - the player to send the table to
8+
identifier [string] - what kind of table you are sending to the client
9+
table [table] - the table you send
10+
Returns: nothing
11+
]]
412
function MSync.net.sendTable(ply, identifier, table)
5-
identifier = identifier or "settings"
13+
local identifier = identifier or "settings"
614

715
net.Start("msync.sendTable")
816
net.WriteString(identifier)
@@ -11,8 +19,16 @@ function MSync.net.sendTable(ply, identifier, table)
1119

1220
end
1321

22+
--[[
23+
Description: Function to send a text message to the client
24+
Arguments:
25+
player [player] - the player you want to send the message to
26+
state [string] - the state of the message, can be "info", "error", "advert"
27+
message [string] - the message you want to send to the client
28+
Returns: nothing
29+
]]
1430
function MSync.net.sendMessage(ply, state, string)
15-
state = state or "info"
31+
local state = state or "info"
1632

1733
net.Start("msync.sendMessage")
1834
net.WriteString(state)
@@ -21,26 +37,42 @@ function MSync.net.sendMessage(ply, state, string)
2137

2238
end
2339

40+
--[[
41+
Description: Net Receiver - Gets called when the client requests a table
42+
Returns: nothing
43+
]]
2444
net.Receive("msync.getTable", function(len, ply)
2545
if not ply:query("msync.getTable") then return end
2646

2747
local identifier = net.ReadString()
2848
MSync.net.sendTable(ply, identifier, MSync[identifier])
2949
end )
3050

51+
--[[
52+
Description: Net Receiver - Gets called when the client sends the settings table to the server
53+
Returns: nothing
54+
]]
3155
net.Receive("msync.sendSettings", function(len, ply)
3256
if not ply:query("msync.sendSettings") then return end
3357

3458
MSync.settings.data = net.ReadTable()
3559
MSync.function.saveSettings()
3660
end )
3761

62+
--[[
63+
Description: Net Receiver - Gets called when the client requests the settings table
64+
Returns: nothing
65+
]]
3866
net.Receive("msync.getSettings", function(len, ply)
3967
if not ply:query("msync.getSettings") then return end
4068

4169
MSync.net.sendTable(ply, "settings", MSync.function.getSafeSettings())
4270
end )
4371

72+
--[[
73+
Description: Net Receiver - Gets called when the client requests the module table
74+
Returns: nothing
75+
]]
4476
net.Receive("msync.getModules", function(len, ply)
4577
if not ply:query("msync.getModules") then return end
4678

0 commit comments

Comments
 (0)