diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..e4560f1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,22 @@ +--- +name: Bug report +about: Open a bug report when something doesnt work as it should +title: Bugreport +labels: bug +assignees: '' + +--- + +**__Description__** +[Describe the bug as good as possible] + +**__Reproduction__** +[How can we re-produce the bug, what did you do to cause it?] + +**__Error Messages__** +``` +[Add error messages here if you recieved any, if not leave this part out] +``` + +**__Optional: Screenshots__** +[Attach screenshots of the bug here if possible] diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..6724821 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,17 @@ +--- +name: Feature request +about: How can we make MSync even better? +title: Feature Request +labels: enhancement +assignees: '' + +--- + +**__Description:__** +[Describe your feature idea as much as possible] + +**__Usage Cases:__** +[In what cases would your feature be usefull] + +**__Optional: Alternatives__** +[Alternative ideas for your feature you have considered. Explain what you came up with and why you think it's your feature is better] diff --git a/lua/msync/client_gui/modules/cl_mrsync.lua b/lua/msync/client_gui/modules/cl_mrsync.lua index c1d9f4e..5731e47 100644 --- a/lua/msync/client_gui/modules/cl_mrsync.lua +++ b/lua/msync/client_gui/modules/cl_mrsync.lua @@ -6,7 +6,7 @@ MSync.modules.MRSync = MSync.modules.MRSync or {} * @package MySQL Rank Sync * @author Aperture Development * @license root_dir/LICENCE - * @version 2.0.0 + * @version 2.1.3 ]] --[[ @@ -16,7 +16,7 @@ MSync.modules.MRSync.info = { Name = "MySQL Rank Sync", ModuleIdentifier = "MRSync", Description = "Synchronise your ranks across your servers", - Version = "2.0.0" + Version = "2.1.3" } --[[ @@ -71,7 +71,8 @@ function MSync.modules.MRSync.adminPanel(sheet) allserver_button:SetPos( 275, 15 ) allserver_button:SetSize( 130, 20 ) allserver_button.DoClick = function() - 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 + 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 + if string.match(allserver_textentry:GetValue(), "^%s*$") or string.match(allserver_textentry:GetValue(), "^%s") or string.match(allserver_textentry:GetValue(), "%s$") then return end allserver_table:AddLine(allserver_textentry:GetValue()) MSync.modules.MRSync.settings.syncall[allserver_textentry:GetValue()] = true allserver_textentry:SetText("") @@ -79,9 +80,6 @@ function MSync.modules.MRSync.adminPanel(sheet) end end - - - local nosync_text = vgui.Create( "DLabel", pnl ) nosync_text:SetPos( 25, 140 ) nosync_text:SetColor( Color( 0, 0, 0 ) ) @@ -120,18 +118,19 @@ function MSync.modules.MRSync.adminPanel(sheet) nosync_button:SetPos( 275, 155 ) nosync_button:SetSize( 130, 20 ) nosync_button.DoClick = function() - 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 + 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 + if string.match(nosync_textentry:GetValue(), "^%s*$") or string.match(nosync_textentry:GetValue(), "^%s") or string.match(nosync_textentry:GetValue(), "%s$") then return end nosync_table:AddLine(nosync_textentry:GetValue()) - MSync.modules.MRSync.settings.nosync[allserver_textentry:GetValue()] = true + MSync.modules.MRSync.settings.nosync[nosync_textentry:GetValue()] = true nosync_textentry:SetText("") MSync.modules.MRSync.sendSettings() end end - if MSync.DBStatus then - MSync.modules.MRSync.getSettings() - end + -- Load settings from the server + MSync.modules.MRSync.getSettings() + -- Wait for settings from the server if not MSync.modules.MRSync.settings then timer.Create("mrsync.t.checkSettings", 1, 0, function() if not MSync.modules.MRSync.settings then return end diff --git a/lua/msync/server/modules/sv_mrsync.lua b/lua/msync/server/modules/sv_mrsync.lua index 6ca90da..4fc2e82 100644 --- a/lua/msync/server/modules/sv_mrsync.lua +++ b/lua/msync/server/modules/sv_mrsync.lua @@ -6,7 +6,7 @@ MSync.modules.MRSync = MSync.modules.MRSync or {} * @package MySQL Rank Sync * @author Aperture Development * @license root_dir/LICENCE - * @version 2.0.1 + * @version 2.1.3 ]] --[[ @@ -16,7 +16,7 @@ MSync.modules.MRSync.info = { Name = "MySQL Rank Sync", ModuleIdentifier = "MRSync", Description = "Synchronise your ranks across your servers", - Version = "2.0.1" + Version = "2.1.3" } --[[ @@ -64,6 +64,35 @@ function MSync.modules.MRSync.init( transaction ) addUserRankQ:start() end + --[[ + Description: Function to save a players rank using steamid and group name + Returns: nothing + ]] + function MSync.modules.MRSync.saveRankByID(steamid, group) + + if MSync.modules.MRSync.settings.nosync[group] then return end; + + local addUserRankQ = MSync.DBServer:prepare( [[ + INSERT INTO `tbl_mrsync` (user_id, rank, server_group) + VALUES ( + (SELECT p_user_id FROM tbl_users WHERE steamid=? AND steamid64=?), + ?, + (SELECT p_group_id FROM tbl_server_grp WHERE group_name=?) + ) + ON DUPLICATE KEY UPDATE rank=VALUES(rank); + ]] ) + addUserRankQ:setString(1, steamid) + addUserRankQ:setString(2, util.SteamIDTo64( steamid )) + addUserRankQ:setString(3, group) + if not MSync.modules.MRSync.settings.syncall[group] then + addUserRankQ:setString(4, MSync.settings.data.serverGroup) + else + addUserRankQ:setString(4, "allservers") + end + + addUserRankQ:start() + end + --[[ Description: Function to load a players rank Returns: nothing @@ -84,6 +113,11 @@ function MSync.modules.MRSync.init( transaction ) loadUserQ:setString(3, MSync.settings.data.serverGroup) function loadUserQ.onData( q, data ) + if not ULib.ucl.groups[data.rank] then + print("[MRSync] Could not load rank "..data.rank.." for "..ply:Nick()..". Rank does not exist on this server") + return + end + if data.rank == ply:GetUserGroup() then return end; ply:SetUserGroup(data.rank) @@ -185,13 +219,20 @@ end ]] function MSync.modules.MRSync.hooks() + -- Load rank on spawn hook.Add("PlayerInitialSpawn", "mrsync.H.loadRank", function(ply) MSync.modules.MRSync.loadRank(ply) end) + -- Save rank on disconnect hook.Add("PlayerDisconnected", "mrsync.H.saveRank", function(ply) MSync.modules.MRSync.saveRank(ply) end) + + -- Save rank on GroupChange + hook.Add("ULibUserGroupChange", "mrsync.H.saveRankOnUpdate", function(sid, _, _, new_group, _) + MSync.modules.MRSync.saveRankByID(sid, new_group) + end) end --[[