1
0
mirror of https://github.com/Earu/EasyChat.git synced 2025-03-04 03:13:20 -05:00

steam block list syncing convar

This commit is contained in:
Earu 2022-10-08 19:01:20 +02:00
parent dc3f796b51
commit 8b8764c5a5
3 changed files with 17 additions and 7 deletions

View File

@ -32,7 +32,8 @@ local EC_NICK_COMPLETE = get_cvar("easychat_nick_complete")
local EC_NICK_PRIORITIZE = get_cvar("easychat_nick_prioritize")
local EC_OUT_CLICK_CLOSE = get_cvar("easychat_out_click_close")
local EC_SERVER_MSG = get_cvar("easychat_server_msg")
local EC_SKIP_STARTUP_MSG = GetConVar("easychat_skip_startup_msg")
local EC_SKIP_STARTUP_MSG = get_cvar("easychat_skip_startup_msg")
local EC_SYNC_STEAM_BLOCKS = get_cvar("easychat_sync_steam_blocks")
-- timestamps
local EC_TIMESTAMPS = get_cvar("easychat_timestamps")
@ -99,6 +100,7 @@ local function create_default_settings()
[EC_OUT_CLICK_CLOSE] = "Close the chat when clicking away",
[EC_SERVER_MSG] = "Show changes made to the server cvars",
[EC_SKIP_STARTUP_MSG] = "Skips annoying addon startup messages (displays in console)",
[EC_SYNC_STEAM_BLOCKS] = "Synchronize your steam block list with EasyChat",
})
settings:AddSpacer(category_name)

View File

@ -460,6 +460,7 @@ if CLIENT then
local EC_OUT_CLICK_CLOSE = CreateConVar("easychat_out_click_close", "1", FCVAR_ARCHIVE, "Clicking outside the chatbox closes it")
local EC_SERVER_MSG = CreateConVar("easychat_server_msg", "1", FCVAR_ARCHIVE, "Shows convars being changed on the server")
local EC_SKIP_STARTUP_MSG = CreateConVar("easychat_skip_startup_msg", "1", FCVAR_ARCHIVE, "Displays random addons startup messages in the console")
local _ = CreateConVar("easychat_sync_steam_blocks", "1", FCVAR_ARCHIVE, "Sync Steam blocked users with EasyChat")
-- timestamps
local EC_TIMESTAMPS = CreateConVar("easychat_timestamps", "0", FCVAR_ARCHIVE, "Display timestamps in the chatbox")

View File

@ -497,9 +497,12 @@ if CLIENT then
EasyChat.BlockedPlayers = util.JSONToTable(BLOCKED_PLAYERS) or {}
local lookup = {}
for _, ply in ipairs(player.GetAll()) do
if ply:GetFriendStatus() == "blocked" then
table.insert(lookup, ply:SteamID())
if GetConVar("easychat_sync_steam_blocks"):GetBool() then
for _, ply in ipairs(player.GetAll()) do
if ply:GetFriendStatus() == "blocked" then
table.insert(lookup, ply:SteamID())
end
end
end
@ -515,7 +518,7 @@ if CLIENT then
end)
end
EasyChat.LoadBlockedPlayers()
hook.Add("Initialize", "EasyChatBlockListInit", EasyChat.LoadBlockedPlayers)
function EasyChat.BlockPlayer(steam_id)
EasyChat.BlockedPlayers[steam_id] = true
@ -549,8 +552,10 @@ if CLIENT then
if not IsValid(ply) then return false end
if not ply:IsPlayer() then return false end
local steam_blocked = (ply:GetFriendStatus() or "") == "blocked"
if steam_blocked then return true end
if GetConVar("easychat_sync_steam_blocks"):GetBool() then
local steam_blocked = (ply:GetFriendStatus() or "") == "blocked"
if steam_blocked then return true end
end
local steam_id = ply:SteamID() or ""
if LocalPlayer():SteamID() == steam_id then return false end
@ -561,6 +566,8 @@ if CLIENT then
-- sync up data for players joining, we dont want a funny steam blocked person to avoid blocking
gameevent.Listen("player_spawn")
hook.Add("player_spawn", TAG, function(data)
if not GetConVar("easychat_sync_steam_blocks"):GetBool() then return end
timer.Simple(10, function()
local ply = Player(data.userid)
if not IsValid(ply) then return end