Files
VnUtest/garrysmod/gamemodes/militaryrp/plugins/death_screen/sh_plugin.lua
2026-03-31 10:27:04 +03:00

139 lines
5.6 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
local PLUGIN = PLUGIN
PLUGIN.name = "Murder Drones Death Screen"
PLUGIN.description = "Добавляет кинематографичный экран смерти в стиле Murder Drones"
PLUGIN.author = "Scripty & Ported to Helix"
-- Конфигурация
ix.config.Add("deathScreenEnabled", true, "Включить экран смерти Murder Drones", nil, {
category = "Death Screen"
})
ix.config.Add("deathScreenDuration", 300, "Длительность показа экрана смерти (секунды)", nil, {
data = {min = 1, max = 600, decimals = 1},
category = "Death Screen"
})
ix.config.Add("deathScreenMinDuration", 20, "Минимальное время до возможности возродиться (секунды)", nil, {
data = {min = 0, max = 60, decimals = 1},
category = "Death Screen"
})
ix.config.Add("deathScreenFadeInSpeed", 5, "Скорость появления экрана", nil, {
data = {min = 1, max = 20, decimals = 1},
category = "Death Screen"
})
ix.config.Add("deathScreenTextFadeSpeed", 0.5, "Скорость появления текста", nil, {
data = {min = 0.1, max = 5, decimals = 1},
category = "Death Screen"
})
ix.config.Add("deathScreenTextColor", Color(132, 43, 60), "Цвет текста экрана смерти", nil, {
category = "Death Screen"
})
ix.config.Add("deathScreenMainText", "YOU'RE DEAD", "Основной текст экрана смерти", nil, {
category = "Death Screen"
})
ix.config.Add("deathScreenSubText", "[IDIOT]", "Подзаголовок экрана смерти", nil, {
category = "Death Screen"
})
ix.config.Add("deathScreenRespawnText", "НАЖМИТЕ [ПРОБЕЛ] ЧТОБЫ ВОЗРОДИТЬСЯ", "Текст подсказки для возрождения", nil, {
category = "Death Screen"
})
ix.config.Add("deathScreenDisableSound", true, "Отключить стандартный звук смерти", nil, {
category = "Death Screen"
})
ix.config.Add("deathPenaltyAmount", 3000, "Сумма штрафа за возрождение", nil, {
data = {min = 0, max = 100000},
category = "Death Screen"
})
ix.config.Add("deathPenaltyWarningText", "При сдаче с вас спишут штраф: %s", "Текст предупреждения о штрафе", nil, {
category = "Death Screen"
})
ix.config.Add("deathRespawnMinBalance", 5000, "Минимальный баланс для возможности сдаться", nil, {
data = {min = 0, max = 100000},
category = "Death Screen"
})
if SERVER then
util.AddNetworkString("ixDeathScreen")
util.AddNetworkString("ixPlayerRespawn")
function PLUGIN:PlayerDeath(ply, inflictor, attacker)
if not ix.config.Get("deathScreenEnabled") then
return
end
local maxDuration = ix.config.Get("deathScreenDuration", 300)
local minDuration = ix.config.Get("deathScreenMinDuration", 20)
local killerName = "Неизвестно"
if (IsValid(attacker)) then
if (attacker:IsPlayer()) then
killerName = attacker:Name()
elseif (attacker:IsNPC()) then
killerName = attacker:GetClass()
elseif (IsValid(attacker:GetOwner()) and attacker:GetOwner():IsPlayer()) then
killerName = attacker:GetOwner():Name()
elseif (attacker.GetCreator and IsValid(attacker:GetCreator()) and attacker:GetCreator():IsPlayer()) then
killerName = attacker:GetCreator():Name()
else
killerName = (attacker:GetClass() != "worldspawn") and attacker:GetClass() or "Окружение"
end
end
net.Start("ixDeathScreen")
net.WriteFloat(maxDuration)
net.WriteFloat(minDuration)
net.WriteString(killerName)
net.Send(ply)
-- Блокируем стандартный спавн Helix
local duration = RespawnTime[ply:GetUserGroup()] or 60
ply.ixDeathTime = RealTime()
ply.ixNextSpawn = RealTime() + duration
ply:SetNetVar("deathTime", CurTime() + maxDuration)
-- Сохраняем реальное минимальное время для проверки
ply.ixDeathScreenRespawnTime = CurTime() + minDuration
end
-- Разрешаем создание стандартного регдолла Helix
function PLUGIN:ShouldSpawnClientRagdoll(ply)
return true
end
net.Receive("ixPlayerRespawn", function(len, ply)
if (IsValid(ply) and !ply:Alive() and ply:GetCharacter()) then
if ((ply.ixDeathScreenRespawnTime or 0) <= CurTime()) then
local character = ply:GetCharacter()
local minBalance = ix.config.Get("deathRespawnMinBalance", 5000)
-- Проверка баланса перед спавном
if (character:GetMoney() < minBalance) then
ply:Notify("У вас недостаточно средств, чтобы сдаться. Нужно минимум " .. ix.currency.Get(minBalance))
return
end
local penalty = ix.config.Get("deathPenaltyAmount", 3000)
if (penalty > 0) then
character:TakeMoney(penalty)
ply:Notify("Вы сдались. С вашего счета списано " .. ix.currency.Get(penalty) .. " штрафа.")
end
ply:Spawn()
end
end
end)
end
ix.util.Include("cl_deathscreen.lua")