Skip to content

Commit

Permalink
Fixed missing system message
Browse files Browse the repository at this point in the history
  • Loading branch information
Shark-vil committed Jun 2, 2023
1 parent 5ea73e2 commit 6303d0c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions lua/background_npcs_core/modules/cl_version_checker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local function version_check()
msg_outdated = 'Вы используете устаревшую версию \'Background NPCs\' :(\n',
msg_latest = 'Вы используете последнюю версию \'Background NPCs\' :)\n',
msg_dev = 'Вы используете версию для разработчиков \'Background NPCs\' :o\n',
msg_upgrade = 'Аддон \'Background NPCs\' был обновлён до версии:\n',
actual_version = 'Актуальная версия - ' .. github_version .. ' : Ваша версия - ' .. bgNPC.VERSION .. '\n',
update_page_1 = 'Используйте консольную команду \'',
update_page_2 = '\' чтобы посмотреть информацию о последнем выпуске.\n',
Expand All @@ -24,6 +25,7 @@ local function version_check()
msg_outdated = 'You are using an outdated version of \'Background NPCs\' :(\n',
msg_latest = 'You are using the latest version of \'Background NPCs\' :)\n',
msg_dev = 'You are using the dev version of \'Background NPCs\' :o\n',
msg_upgrade = 'The \'Background NPCs\' addon has been updated to version:\n',
actual_version = 'Actual version - ' .. github_version .. ' : Your version - ' .. bgNPC.VERSION .. '\n',
update_page_1 = 'Use the console command \'',
update_page_2 = '\' to view information about the latest release.\n',
Expand All @@ -33,6 +35,11 @@ local function version_check()
local lang = GetConVar('cl_language'):GetString() == 'russian' and ru_lang or en_lang
local v_github = tonumber(string.Replace(github_version, '.', ''))
local v_addon = tonumber(string.Replace(bgNPC.VERSION, '.', ''))
local v_storage = '[out of sync]'

if file.Exists('background_npcs/version.txt', 'DATA') then
v_storage = file.Read('background_npcs/version.txt', 'DATA')
end

if v_addon < v_github then

Expand All @@ -59,6 +66,12 @@ local function version_check()
text_command_color, lang.command, text_color_info, lang.update_page_2)

end

if v_storage ~= bgNPC.VERSION then
local text_color = Color(135, 196, 211)
chat.AddText(Color(255, 0, 0), '[ADMIN] ', text_color, lang.msg_upgrade, text_version_color, v_storage .. ' -> ' .. bgNPC.VERSION)
file.Write('background_npcs/version.txt', bgNPC.VERSION)
end
end,
function(message)
MsgN('[Background NPCs] Failed to check the actual version:\n' .. message)
Expand Down
2 changes: 1 addition & 1 deletion lua/background_npcs_core/modules/sh_poll.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if SERVER then
end
end)
else
hook.Add('slib.FirstPlayerSpawn', 'BGN_CheckAddonVersion', function(ply)
hook.Add('slib.FirstPlayerSpawn', 'BGN_CheckAddonPulls', function(ply)
if not ply:IsAdmin() and not ply:IsSuperAdmin() then return end

if file.Exists('background_npcs/poll.txt', 'DATA') then
Expand Down

0 comments on commit 6303d0c

Please sign in to comment.