Как портировать нижеупомянутые фрагменты кода с ClockWork на Helix?
sv_hooks.lua:
function PLUGIN:OnePlayerSecond(player, curTime, infoTable)
if player:GetCharacter() and player:Alive() then
local jailtime = player:GetCharacterData("CP_JTime", 0)
local jailreason = player:GetCharacterData("CP_JReason", "#N")
if jailreason != "#N" then
if jailtime > 0 then
player:SetCharacterData("CP_JTime", jailtime - 1)
elseif jailtime <= 0 then
if !player.isolationRemind or CurTime() >= player.isolationRemind then
local mark = (player:GetFaction() == FACTION_MPF or player:GetFaction() == FACTION_OTA) and " юнита " or " объекта "
self:SayCPRadio(nil, "Изоляция"..mark.."#"..Schema:GetDigits(player).." завершена.")
player.isolationRemind = CurTime() + 60
end
end
end
end
end
sh_plugin.lua:
local PLUGIN = PLUGIN
util.Include("sv_hooks.lua")
sh_jailrequest.lua:
local PLUGIN = PLUGIN
local COMMAND = cw.command:New("JailRequest");
COMMAND.tip = "Request an isolation for citizen.";
COMMAND.text = "<string CID> <string REASON> <number TIME(min)>";
COMMAND.flags = bit.bor(CMD_DEFAULT, CMD_DEATHCODE, CMD_FALLENOVER);
COMMAND.arguments = 3;
-- Called when the command has been run.
function COMMAND:OnRun(combine, arguments)
if combine:GetFaction() == FACTION_MPF then
local stringCID = arguments[1]
local stringREASON = arguments[2]
local numberTIME = tonumber(arguments[3])
for k,v in pairs(player.GetAll()) do
if Schema:GetDigits(v) == stringCID then
if v:GetCharacterData("CP_JReason") == "#N" then
cw.player:SayRadio(combine, "Центр, запрашиваю изоляцию гражданина #"..stringCID..", причина: "..stringREASON..", время изоляции: "..numberTIME.." минут.", true)
v:SetCharacterData("CP_JReason", stringREASON)
v:SetCharacterData("CP_JTime", numberTIME * 60)
timer.Simple(2, function()
chatbox.AddText(combine, center.."Запрос изоляции гражданина #"..stringCID.." был подтвержден."..centerend, {filter = "default", textColor = Color(10, 200, 10, 255), icon = false, radius = 0})
end)
end
return
end
end
end
end;
COMMAND:Register();
sh_jailinforequest.lua:
local PLUGIN = PLUGIN
local COMMAND = cw.command:New("JailInfoRequest");
COMMAND.tip = "Request information about isolated citizens.";
COMMAND.text = "";
COMMAND.flags = bit.bor(CMD_DEFAULT, CMD_DEATHCODE, CMD_FALLENOVER);
COMMAND.arguments = 0;
-- Called when the command has been run.
function COMMAND:OnRun(combine, arguments)
local center = "Центр говорит по рации <:: "
local centerend = " ::>"
if Schema:PlayerIsCombine(combine) then
cw.player:SayRadio(combine, "Запрашиваю информацию о заключённых.", true)
timer.Simple(2, function()
combine:EmitSound("npc/combine_soldier/vo/off"..math.random(1, 2)..".wav")
chatbox.AddText(combine, center.."Запрос информации о заключённых был подтвержден."..centerend, {filter = "default", textColor = Color(10, 200, 10, 255), icon = false, radius = 0})
local i = 0
for k, v in pairs(player.GetAll()) do
if v:GetCharacterData("CP_JReason", "#N") != "#N" then
local citizenID = Schema:GetDigits(v)
i = i + 1
chatbox.AddText(combine, center..i..". "..v:Name().." #"..citizenID.."."..centerend, {filter = "default", textColor = Color(10, 200, 10, 255), icon = false, radius = 0})
chatbox.AddText(combine, center.."Причина задержания: "..v:GetCharacterData("CP_JReason").."."..centerend, {filter = "default", textColor = Color(10, 200, 10, 255), icon = false, radius = 0})
chatbox.AddText(combine, center.."Осталось: "..math.Round((tonumber(v:GetCharacterData("CP_JTime", 0))/60)).." минут(ы/а)."..centerend, {filter = "default", textColor = Color(10, 200, 10, 255), icon = false, radius = 0})
end
end
end)
end
end
COMMAND:Register();