Skip to content

Commit

Permalink
Merge pull request #43 from Aperture-Development/development
Browse files Browse the repository at this point in the history
Feature Update
  • Loading branch information
ApertureDevelopment authored May 14, 2020
2 parents ff34fb7 + 90df549 commit a6c0619
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 13 deletions.
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -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]
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -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]
21 changes: 10 additions & 11 deletions lua/msync/client_gui/modules/cl_mrsync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
]]

--[[
Expand All @@ -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"
}

--[[
Expand Down Expand Up @@ -71,17 +71,15 @@ 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("")
MSync.modules.MRSync.sendSettings()
end
end




local nosync_text = vgui.Create( "DLabel", pnl )
nosync_text:SetPos( 25, 140 )
nosync_text:SetColor( Color( 0, 0, 0 ) )
Expand Down Expand Up @@ -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
Expand Down
45 changes: 43 additions & 2 deletions lua/msync/server/modules/sv_mrsync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
]]

--[[
Expand All @@ -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"
}

--[[
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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

--[[
Expand Down

0 comments on commit a6c0619

Please sign in to comment.