Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add admin checks to admin networking #1371

Merged
merged 2 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lua/pac3/editor/server/bans.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
end

do -- check if this needs to be rebuilt
local k,v = next(bans)

Check warning on line 15 in lua/pac3/editor/server/bans.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: k

Check warning on line 15 in lua/pac3/editor/server/bans.lua

View workflow job for this annotation

GitHub Actions / lint

"Space after comma"

Style: Please add a space after the comma
if isstring(v) then
local temp = {}

for k,v in pairs(bans) do

Check warning on line 19 in lua/pac3/editor/server/bans.lua

View workflow job for this annotation

GitHub Actions / lint

"Space after comma"

Style: Please add a space after the comma
temp[util.CRC("gm_" .. v .. "_gm")] = {steamid = v, name = k}
end

Expand Down Expand Up @@ -117,10 +117,14 @@
end

net.Receive("pac.BanUpdate", function(len, ply)
if not ply:IsAdmin() then
return
end

pac.Message("Received ban list update operation from : ", ply)
pac.Message("Time : ", os.date( "%a %X %x", os.time() ))
local playerlist = net.ReadTable()
for i,v in pairs(playerlist) do

Check warning on line 127 in lua/pac3/editor/server/bans.lua

View workflow job for this annotation

GitHub Actions / lint

"Space after comma"

Style: Please add a space after the comma
if playerlist[i] == "Allowed" then
pace.Unban(i)
elseif playerlist[i] == "Banned" then
Expand All @@ -130,8 +134,12 @@
end
end)

net.Receive("pac.RequestBanStates", function(len,ply)

Check warning on line 137 in lua/pac3/editor/server/bans.lua

View workflow job for this annotation

GitHub Actions / lint

"Space after comma"

Style: Please add a space after the comma
if not ply:IsAdmin() then
return
end

local archive = net.ReadBool()

Check warning on line 142 in lua/pac3/editor/server/bans.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: archive
pac.Message("Received ban list request from : ", ply)
pac.Message("Time : ", os.date( "%a %X %x", os.time() ))
local players = {}
Expand Down
8 changes: 7 additions & 1 deletion lua/pac3/editor/server/combat_bans.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
end

do -- check if this needs to be rebuilt
local k,v = next(banstates)

Check warning on line 12 in lua/pac3/editor/server/combat_bans.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: k

Check warning on line 12 in lua/pac3/editor/server/combat_bans.lua

View workflow job for this annotation

GitHub Actions / lint

"Space after comma"

Style: Please add a space after the comma
if isstring(v) then
local temp = {}

for k,v in pairs(banstates) do

Check warning on line 16 in lua/pac3/editor/server/combat_bans.lua

View workflow job for this annotation

GitHub Actions / lint

"Space after comma"

Style: Please add a space after the comma
permission = pac.global_combat_whitelist[player.GetBySteamID(k)] or "Default"
temp[util.CRC("gm_" .. v .. "_gm")] = {steamid = v, name = k, permission = permission}
end
Expand Down Expand Up @@ -46,7 +46,10 @@
end


net.Receive("pac.CombatBanUpdate", function()
net.Receive("pac.CombatBanUpdate", function(len, player)
if not player:IsAdmin() then
return
end
--get old states first
pac.old_tbl_on_file = get_combat_ban_states()

Expand Down Expand Up @@ -80,6 +83,9 @@
end)

net.Receive("pac.RequestCombatBanStates", function(len, ply)
if not ply:IsAdmin() then
return
end
pac.global_combat_whitelist = get_combat_ban_states()
net.Start("pac.SendCombatBanStates")
net.WriteTable(pac.global_combat_whitelist)
Expand All @@ -93,7 +99,7 @@

concommand.Add("pac_read_combat_bans", function()
print("PAC3 combat bans and whitelist:")
for k,v in pairs(get_combat_ban_states()) do

Check warning on line 102 in lua/pac3/editor/server/combat_bans.lua

View workflow job for this annotation

GitHub Actions / lint

"Space after comma"

Style: Please add a space after the comma
print("\t" .. v.nick .. " is " .. v.permission .. " [" .. v.steamid .. "]")
end
end)
Expand Down
Loading