63 lines
2.4 KiB
Lua
63 lines
2.4 KiB
Lua
local PLUGIN = PLUGIN
|
||
|
||
-- Клиентская часть HUD
|
||
net.Receive("ParachuteState", function()
|
||
local state = net.ReadBool()
|
||
LocalPlayer().Parachuting = state
|
||
|
||
if state then
|
||
-- Запуск звука полёта
|
||
if LoopingSound then
|
||
LoopingSound:Stop()
|
||
end
|
||
|
||
LoopingSound = CreateSound(LocalPlayer(), "v92/bf2/vehicles/air/parachute/parachute_ride_loop.wav")
|
||
LoopingSound:PlayEx(ix.config.Get("parachuteVolume", 0.7), 100)
|
||
else
|
||
-- Остановка звука
|
||
if LoopingSound then
|
||
LoopingSound:Stop()
|
||
end
|
||
end
|
||
end)
|
||
|
||
function PLUGIN:HUDPaint()
|
||
local client = LocalPlayer()
|
||
if not client:Alive() or not IsValid(client) then return end
|
||
if not IsValid(client:GetActiveWeapon()) then return end
|
||
if client:GetActiveWeapon():GetClass() ~= "parachute_swep" then return end
|
||
|
||
local reload_time = ix.config.Get("parachuteReloadTime", 20)
|
||
local width = ScrW() * 0.15
|
||
local height = ScrH() * 0.03
|
||
local progression = (reload_time - math.abs(math.min(CurTime() - client:GetNW2Int("r_parachute"), 0))) / reload_time
|
||
|
||
-- Фон прогресс-бара
|
||
draw.RoundedBox(1, (ScrW() / 2) - (width / 2), ScrH() / 1.08, width, height, Color(59, 59, 59, 255))
|
||
surface.SetDrawColor(89, 89, 89, 128)
|
||
surface.DrawOutlinedRect((ScrW() / 2) - (width / 2) + 1, (ScrH() / 1.08) + 2, width - 2, height - 2, 1)
|
||
|
||
-- Полоса прогресса
|
||
draw.RoundedBox(1, (ScrW() / 2) - (width / 2) + 3, ScrH() / 1.08 + 3, progression * (width - 6), height - 6, Color(176, 151, 28, 255))
|
||
|
||
-- Текст подсказки
|
||
if progression >= 1 then
|
||
draw.SimpleText("ЛКМ - Раскрыть парашют", "DermaDefault", ScrW() / 2, ScrH() / 1.08 - 20, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
|
||
else
|
||
draw.SimpleText("Перезарядка...", "DermaDefault", ScrW() / 2, ScrH() / 1.08 - 20, Color(255, 100, 100, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
|
||
end
|
||
|
||
-- Если парашют активен
|
||
if client.Parachuting then
|
||
draw.SimpleText("Ctrl + Shift - Отцепить парашют", "DermaDefault", ScrW() / 2, ScrH() / 1.08 - 40, Color(255, 200, 100, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
|
||
draw.SimpleText("E - Замедлить спуск", "DermaDefault", ScrW() / 2, ScrH() / 1.08 - 60, Color(150, 200, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
|
||
end
|
||
end
|
||
|
||
-- Остановка звука при выходе
|
||
function PLUGIN:ShutDown()
|
||
if LoopingSound then
|
||
LoopingSound:Stop()
|
||
end
|
||
end
|