@@ -6,7 +6,7 @@ MSync.modules.MRSync = MSync.modules.MRSync or {}
66 * @package MySQL Rank Sync
77 * @author Aperture Development
88 * @license root_dir/LICENCE
9- * @version 2.0.0
9+ * @version 2.1.3
1010]]
1111
1212--[[
@@ -16,13 +16,13 @@ MSync.modules.MRSync.info = {
1616 Name = " MySQL Rank Sync" ,
1717 ModuleIdentifier = " MRSync" ,
1818 Description = " Synchronise your ranks across your servers" ,
19- Version = " 2.0.0 "
19+ Version = " 2.1.3 "
2020}
2121
2222--[[
2323 Define additional functions that are later used
2424]]
25- function MSync .modules .MRSync .init ()
25+ function MSync .modules .MRSync .init ()
2626
2727end
2828
@@ -67,21 +67,19 @@ function MSync.modules.MRSync.adminPanel(sheet)
6767 end
6868
6969 local allserver_button = vgui .Create ( " DButton" , pnl )
70- allserver_button :SetText ( " Add" )
70+ allserver_button :SetText ( " Add" )
7171 allserver_button :SetPos ( 275 , 15 )
7272 allserver_button :SetSize ( 130 , 20 )
73- allserver_button .DoClick = function ()
74- if allserver_textentry :GetValue () and not MSync .modules .MRSync .settings .nosync [allserver_textentry :GetValue ()] and not MSync .modules .MRSync .settings .syncall [allserver_textentry :GetValue ()] then
73+ allserver_button .DoClick = function ()
74+ if string.len (allserver_textentry :GetValue ()) > 0 and not MSync .modules .MRSync .settings .nosync [allserver_textentry :GetValue ()] and not MSync .modules .MRSync .settings .syncall [allserver_textentry :GetValue ()] then
75+ if string.match (allserver_textentry :GetValue (), " ^%s*$" ) or string.match (allserver_textentry :GetValue (), " ^%s" ) or string.match (allserver_textentry :GetValue (), " %s$" ) then return end
7576 allserver_table :AddLine (allserver_textentry :GetValue ())
7677 MSync .modules .MRSync .settings .syncall [allserver_textentry :GetValue ()] = true
7778 allserver_textentry :SetText (" " )
7879 MSync .modules .MRSync .sendSettings ()
7980 end
8081 end
8182
82-
83-
84-
8583 local nosync_text = vgui .Create ( " DLabel" , pnl )
8684 nosync_text :SetPos ( 25 , 140 )
8785 nosync_text :SetColor ( Color ( 0 , 0 , 0 ) )
@@ -116,42 +114,43 @@ function MSync.modules.MRSync.adminPanel(sheet)
116114 end
117115
118116 local nosync_button = vgui .Create ( " DButton" , pnl )
119- nosync_button :SetText ( " Add" )
117+ nosync_button :SetText ( " Add" )
120118 nosync_button :SetPos ( 275 , 155 )
121119 nosync_button :SetSize ( 130 , 20 )
122- nosync_button .DoClick = function ()
123- if nosync_textentry :GetValue () and not MSync .modules .MRSync .settings .nosync [allserver_textentry :GetValue ()] and not MSync .modules .MRSync .settings .syncall [allserver_textentry :GetValue ()] then
120+ nosync_button .DoClick = function ()
121+ if string.len (nosync_textentry :GetValue ()) > 0 and not MSync .modules .MRSync .settings .nosync [nosync_textentry :GetValue ()] and not MSync .modules .MRSync .settings .syncall [nosync_textentry :GetValue ()] then
122+ if string.match (nosync_textentry :GetValue (), " ^%s*$" ) or string.match (nosync_textentry :GetValue (), " ^%s" ) or string.match (nosync_textentry :GetValue (), " %s$" ) then return end
124123 nosync_table :AddLine (nosync_textentry :GetValue ())
125- MSync .modules .MRSync .settings .nosync [allserver_textentry :GetValue ()] = true
124+ MSync .modules .MRSync .settings .nosync [nosync_textentry :GetValue ()] = true
126125 nosync_textentry :SetText (" " )
127126 MSync .modules .MRSync .sendSettings ()
128127 end
129128 end
130129
131- if MSync .DBStatus then
132- MSync .modules .MRSync .getSettings ()
133- end
130+ -- Load settings from the server
131+ MSync .modules .MRSync .getSettings ()
134132
133+ -- Wait for settings from the server
135134 if not MSync .modules .MRSync .settings then
136135 timer .Create (" mrsync.t.checkSettings" , 1 , 0 , function ()
137136 if not MSync .modules .MRSync .settings then return end
138137
139- for k ,_ in pairs (MSync .modules .MRSync .settings .syncall ) do
138+ for k ,_ in pairs (MSync .modules .MRSync .settings .syncall ) do
140139 allserver_table :AddLine (k )
141140 end
142-
143- for k ,_ in pairs (MSync .modules .MRSync .settings .nosync ) do
141+
142+ for k ,_ in pairs (MSync .modules .MRSync .settings .nosync ) do
144143 nosync_table :AddLine (k )
145144 end
146145
147146 timer .Remove (" mrsync.t.checkSettings" )
148147 end )
149148 else
150- for k ,_ in pairs (MSync .modules .MRSync .settings .syncall ) do
149+ for k ,_ in pairs (MSync .modules .MRSync .settings .syncall ) do
151150 allserver_table :AddLine (k )
152151 end
153152
154- for k ,_ in pairs (MSync .modules .MRSync .settings .nosync ) do
153+ for k ,_ in pairs (MSync .modules .MRSync .settings .nosync ) do
155154 nosync_table :AddLine (k )
156155 end
157156 end
@@ -171,14 +170,14 @@ end
171170--[[
172171 Define net receivers and util.AddNetworkString
173172]]
174- function MSync .modules .MRSync .net ()
173+ function MSync .modules .MRSync .net ()
175174
176175 --[[
177176 Description: Function to send the mrsync settings to the client
178177 Arguments:
179178 player [player] - the player that wants to open the admin GUI
180179 Returns: nothing
181- ]]
180+ ]]
182181 function MSync .modules .MRSync .sendSettings ()
183182 net .Start (" msync.mrsync.sendSettings" )
184183 net .WriteTable (MSync .modules .MRSync .settings )
@@ -190,7 +189,7 @@ function MSync.modules.MRSync.net()
190189 Arguments:
191190 player [player] - the player that wants to open the admin GUI
192191 Returns: nothing
193- ]]
192+ ]]
194193 function MSync .modules .MRSync .getSettings ()
195194 net .Start (" msync.mrsync.getSettings" )
196195 net .SendToServer ()
@@ -199,7 +198,7 @@ function MSync.modules.MRSync.net()
199198 --[[
200199 Description: Net Receiver - Gets called when the client requests the settings table
201200 Returns: nothing
202- ]]
201+ ]]
203202 net .Receive (" msync.mrsync.sendSettingsPly" , function (len , ply )
204203 MSync .modules .MRSync .settings = net .ReadTable ()
205204 end )
@@ -208,14 +207,14 @@ end
208207--[[
209208 Define ulx Commands and overwrite common ulx functions (module does not get loaded until ulx has fully been loaded)
210209]]
211- function MSync .modules .MRSync .ulx ()
212-
210+ function MSync .modules .MRSync .ulx ()
211+
213212end
214213
215214--[[
216215 Define hooks your module is listening on e.g. PlayerDisconnect
217216]]
218- function MSync .modules .MRSync .hooks ()
217+ function MSync .modules .MRSync .hooks ()
219218
220219end
221220
0 commit comments