Skip to content

Commit a6c0619

Browse files
Merge pull request #43 from Aperture-Development/development
Feature Update
2 parents ff34fb7 + 90df549 commit a6c0619

File tree

4 files changed

+92
-13
lines changed

4 files changed

+92
-13
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: Bug report
3+
about: Open a bug report when something doesnt work as it should
4+
title: Bugreport
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
**__Description__**
11+
[Describe the bug as good as possible]
12+
13+
**__Reproduction__**
14+
[How can we re-produce the bug, what did you do to cause it?]
15+
16+
**__Error Messages__**
17+
```
18+
[Add error messages here if you recieved any, if not leave this part out]
19+
```
20+
21+
**__Optional: Screenshots__**
22+
[Attach screenshots of the bug here if possible]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Feature request
3+
about: How can we make MSync even better?
4+
title: Feature Request
5+
labels: enhancement
6+
assignees: ''
7+
8+
---
9+
10+
**__Description:__**
11+
[Describe your feature idea as much as possible]
12+
13+
**__Usage Cases:__**
14+
[In what cases would your feature be usefull]
15+
16+
**__Optional: Alternatives__**
17+
[Alternative ideas for your feature you have considered. Explain what you came up with and why you think it's your feature is better]

lua/msync/client_gui/modules/cl_mrsync.lua

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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,7 +16,7 @@ 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
--[[
@@ -71,17 +71,15 @@ function MSync.modules.MRSync.adminPanel(sheet)
7171
allserver_button:SetPos( 275, 15 )
7272
allserver_button:SetSize( 130, 20 )
7373
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
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 ) )
@@ -120,18 +118,19 @@ function MSync.modules.MRSync.adminPanel(sheet)
120118
nosync_button:SetPos( 275, 155 )
121119
nosync_button:SetSize( 130, 20 )
122120
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
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

lua/msync/server/modules/sv_mrsync.lua

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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.1
9+
* @version 2.1.3
1010
]]
1111

1212
--[[
@@ -16,7 +16,7 @@ MSync.modules.MRSync.info = {
1616
Name = "MySQL Rank Sync",
1717
ModuleIdentifier = "MRSync",
1818
Description = "Synchronise your ranks across your servers",
19-
Version = "2.0.1"
19+
Version = "2.1.3"
2020
}
2121

2222
--[[
@@ -64,6 +64,35 @@ function MSync.modules.MRSync.init( transaction )
6464
addUserRankQ:start()
6565
end
6666

67+
--[[
68+
Description: Function to save a players rank using steamid and group name
69+
Returns: nothing
70+
]]
71+
function MSync.modules.MRSync.saveRankByID(steamid, group)
72+
73+
if MSync.modules.MRSync.settings.nosync[group] then return end;
74+
75+
local addUserRankQ = MSync.DBServer:prepare( [[
76+
INSERT INTO `tbl_mrsync` (user_id, rank, server_group)
77+
VALUES (
78+
(SELECT p_user_id FROM tbl_users WHERE steamid=? AND steamid64=?),
79+
?,
80+
(SELECT p_group_id FROM tbl_server_grp WHERE group_name=?)
81+
)
82+
ON DUPLICATE KEY UPDATE rank=VALUES(rank);
83+
]] )
84+
addUserRankQ:setString(1, steamid)
85+
addUserRankQ:setString(2, util.SteamIDTo64( steamid ))
86+
addUserRankQ:setString(3, group)
87+
if not MSync.modules.MRSync.settings.syncall[group] then
88+
addUserRankQ:setString(4, MSync.settings.data.serverGroup)
89+
else
90+
addUserRankQ:setString(4, "allservers")
91+
end
92+
93+
addUserRankQ:start()
94+
end
95+
6796
--[[
6897
Description: Function to load a players rank
6998
Returns: nothing
@@ -84,6 +113,11 @@ function MSync.modules.MRSync.init( transaction )
84113
loadUserQ:setString(3, MSync.settings.data.serverGroup)
85114

86115
function loadUserQ.onData( q, data )
116+
if not ULib.ucl.groups[data.rank] then
117+
print("[MRSync] Could not load rank "..data.rank.." for "..ply:Nick()..". Rank does not exist on this server")
118+
return
119+
end
120+
87121
if data.rank == ply:GetUserGroup() then return end;
88122

89123
ply:SetUserGroup(data.rank)
@@ -185,13 +219,20 @@ end
185219
]]
186220
function MSync.modules.MRSync.hooks()
187221

222+
-- Load rank on spawn
188223
hook.Add("PlayerInitialSpawn", "mrsync.H.loadRank", function(ply)
189224
MSync.modules.MRSync.loadRank(ply)
190225
end)
191226

227+
-- Save rank on disconnect
192228
hook.Add("PlayerDisconnected", "mrsync.H.saveRank", function(ply)
193229
MSync.modules.MRSync.saveRank(ply)
194230
end)
231+
232+
-- Save rank on GroupChange
233+
hook.Add("ULibUserGroupChange", "mrsync.H.saveRankOnUpdate", function(sid, _, _, new_group, _)
234+
MSync.modules.MRSync.saveRankByID(sid, new_group)
235+
end)
195236
end
196237

197238
--[[

0 commit comments

Comments
 (0)