Skip to content

Commit

Permalink
Изменение логики на выводы по вкл/выкл автоблокировки
Browse files Browse the repository at this point in the history
- правки локализации
  • Loading branch information
Alexell committed Feb 1, 2022
1 parent 320b9be commit 1ed38d0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
41 changes: 25 additions & 16 deletions lua/autorun/metrostroi_advanced_init.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
return
------------------------ Metrostroi Advanced -------------------------
-- Developers:
-- Alexell | https://steamcommunity.com/profiles/76561198210303223
Expand All @@ -14,9 +13,7 @@ if not Metrostroi or not Metrostroi.Version or Metrostroi.Version < 1537278077 t
end

-- Создаем MetrostroiAdvanced глобально
if not MetrostroiAdvanced then
MetrostroiAdvanced = {}
end
MetrostroiAdvanced = MetrostroiAdvanced or {}
if SERVER then
MetrostroiAdvanced.TrainList = {}
MetrostroiAdvanced.StationsIgnore = {}
Expand Down Expand Up @@ -405,59 +402,71 @@ if SERVER then
if comm == "!sactiv" then
local route_found = false
local route_opened = false
local names = ""
for _, ent in pairs(ents.FindByClass("gmod_track_signal")) do
if ent.Routes then
for RouteID, RouteInfo in pairs(ent.Routes) do
if (RouteInfo.RouteName and RouteInfo.RouteName:upper() == Name:upper() or Name == "*") and RouteInfo.Emer then
route_found = true
if ent.LastOpenedRoute and k != ent.LastOpenedRoute then ent:CloseRoute(self.LastOpenedRoute) end
RouteInfo.IsOpened = true
route_opened = true
if not RouteInfo.IsOpened then
RouteInfo.IsOpened = true
route_opened = true
end
if names == "" then names = ent.Name
else names = names ..", "..ent.Name
end
end
end
end
end
end
if route_found and route_opened then
timer.Simple(0.2, function()
ulx.fancyLog("#s "..lang("OpenedEmerRoute").." #s.", ply:Nick(), Name:upper())
ulx.fancyLog("#s "..lang("OpenedEmerRoute").." #s.", ply:Nick(), names)
end)
elseif route_found and not route_opened then
timer.Simple(0.2, function()
ply:ChatPrint(lang("EmerRoute").." "..Name:upper().." "..lang("AlreadyOpened")..".")
ply:ChatPrint(lang("EmerRoute").." "..names.." "..lang("AlreadyEnabled")..".")
end)
end
if not route_found then
timer.Simple(0.2, function()
ply:ChatPrint(lang("EmerRoute").." "..Name:upper().." "..lang("NotFound")..".")
ply:ChatPrint(lang("EmerRoute").." "..names.." "..lang("NotFound")..".")
end)
end
elseif comm == "!sdeactiv" then
local route_found = false
local route_closed = false
local names = ""
for _, ent in pairs(ents.FindByClass("gmod_track_signal")) do
if ent.Routes then
for RouteID, RouteInfo in pairs(ent.Routes) do
if (RouteInfo.RouteName and RouteInfo.RouteName:upper() == Name:upper() or Name == "*") and RouteInfo.Emer then
route_found = true
if ent.LastOpenedRoute and k != ent.LastOpenedRoute then ent:CloseRoute(self.LastOpenedRoute) end
RouteInfo.IsOpened = false
route_closed = true
if RouteInfo.IsOpened then
RouteInfo.IsOpened = false
route_closed = true
end
if names == "" then names = ent.Name
else names = names ..", "..ent.Name
end
end
end
end
end
end
if route_found and route_closed then
timer.Simple(0.2, function()
ulx.fancyLog("#s "..lang("ClosedEmerRoute").." #s.", ply:Nick(), Name:upper())
ulx.fancyLog("#s "..lang("ClosedEmerRoute").." #s.", ply:Nick(), names)
end)
elseif route_found and not route_closed then
timer.Simple(0.2, function()
ply:ChatPrint(lang("EmerRoute").." "..Name:upper().." "..lang("AlreadyClosed")..".")
ply:ChatPrint(lang("EmerRoute").." "..names.." "..lang("AlreadyDisabled")..".")
end)
end
if not route_found then
timer.Simple(0.2, function()
ply:ChatPrint(lang("EmerRoute").." "..Name:upper().." "..lang("NotFound")..".")
ply:ChatPrint(lang("EmerRoute").." "..names.." "..lang("NotFound")..".")
end)
end
elseif comm == "!sclose" then
Expand Down
8 changes: 5 additions & 3 deletions lua/metrostroi_advanced/language/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ MetrostroiAdvanced.Lang["Afkmins"] = "minute(s)"
MetrostroiAdvanced.Lang["Afkmin1"] = "minute"
MetrostroiAdvanced.Lang["AfkKick"] = "kicked for being AFK"
MetrostroiAdvanced.Lang["PressedButton"] = "pressed button"
MetrostroiAdvanced.Lang["OpenedEmerRoute"] = "opened emergency route"
MetrostroiAdvanced.Lang["ClosedEmerRoute"] = "opened emergency route"
MetrostroiAdvanced.Lang["EmerRoute"] = "Emergency route"
MetrostroiAdvanced.Lang["OpenedEmerRoute"] = "opened emergency route on signal(s)"
MetrostroiAdvanced.Lang["ClosedEmerRoute"] = "closed emergency route on signal(s)"
MetrostroiAdvanced.Lang["EmerRoute"] = "Emergency route on signal(s)"
MetrostroiAdvanced.Lang["AlreadyOpened"] = "is already opened"
MetrostroiAdvanced.Lang["AlreadyClosed"] = "is already closed"
MetrostroiAdvanced.Lang["AlreadyEnabled"] = "is already opened"
MetrostroiAdvanced.Lang["AlreadyDisabled"] = "is already closed"
MetrostroiAdvanced.Lang["SignalOrRoute"] = "Signal/Route"
MetrostroiAdvanced.Lang["ClosedSignal"] = "closed signal"
MetrostroiAdvanced.Lang["ClosedRoute"] = "closed route"
Expand Down
8 changes: 5 additions & 3 deletions lua/metrostroi_advanced/language/ru.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ MetrostroiAdvanced.Lang["Afkmins"] = "минут(ы)"
MetrostroiAdvanced.Lang["Afkmin1"] = "минуту"
MetrostroiAdvanced.Lang["AfkKick"] = "отключен за бездействие"
MetrostroiAdvanced.Lang["PressedButton"] = "нажал кнопку"
MetrostroiAdvanced.Lang["OpenedEmerRoute"] = "opened emergency route"
MetrostroiAdvanced.Lang["ClosedEmerRoute"] = "closed emergency route"
MetrostroiAdvanced.Lang["EmerRoute"] = "Emergency route"
MetrostroiAdvanced.Lang["OpenedEmerRoute"] = "включил резервную АБ на светофоре(ах)"
MetrostroiAdvanced.Lang["ClosedEmerRoute"] = "отключил резервную АБ на светофоре(ах)"
MetrostroiAdvanced.Lang["EmerRoute"] = "Резервная АБ на светофоре(ах)"
MetrostroiAdvanced.Lang["AlreadyOpened"] = "уже открыт"
MetrostroiAdvanced.Lang["AlreadyClosed"] = "уже закрыт"
MetrostroiAdvanced.Lang["AlreadyEnabled"] = "уже включена"
MetrostroiAdvanced.Lang["AlreadyDisabled"] = "уже отключена"
MetrostroiAdvanced.Lang["SignalOrRoute"] = "Светофор/Маршрут"
MetrostroiAdvanced.Lang["ClosedSignal"] = "закрыл светофор"
MetrostroiAdvanced.Lang["ClosedRoute"] = "закрыл маршрут"
Expand Down

0 comments on commit 1ed38d0

Please sign in to comment.