add sborka
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
-- d:\ft 4.0\VnU\garrysmod\gamemodes\militaryrp\plugins\killzone\sh_plugin.lua
|
||||
|
||||
local PLUGIN = PLUGIN
|
||||
|
||||
PLUGIN.name = "Killzone Camper Punishment"
|
||||
PLUGIN.author = "Scripty"
|
||||
PLUGIN.description = "Punishes campers in specific zones with a barrage of bombs after 5 minutes."
|
||||
|
||||
-- Определение киллзон
|
||||
PLUGIN.zones = {
|
||||
{
|
||||
min = Vector(6520, -538, -5000), -- Опустил ниже на всякий случай
|
||||
max = Vector(8129, 14097, 10000), -- Поднял до неба
|
||||
name = "Killzone 1"
|
||||
},
|
||||
{
|
||||
min = Vector(8129, -538, -5000),
|
||||
max = Vector(15312, 2213, 10000),
|
||||
name = "Killzone 2"
|
||||
}
|
||||
}
|
||||
|
||||
ix.config.Add("killzonePunishDelay", 300, "Время стоянки в киллзоне до начала наказания (секунды).", nil, {
|
||||
data = {min = 1, max = 3600},
|
||||
category = "Killzone"
|
||||
})
|
||||
|
||||
ix.util.Include("sv_plugin.lua")
|
||||
141
garrysmod/gamemodes/militaryrp/plugins/killzone/sv_plugin.lua
Normal file
141
garrysmod/gamemodes/militaryrp/plugins/killzone/sv_plugin.lua
Normal file
@@ -0,0 +1,141 @@
|
||||
-- d:\ft 4.0\VnU\garrysmod\gamemodes\militaryrp\plugins\killzone\sv_plugin.lua
|
||||
|
||||
local PLUGIN = PLUGIN
|
||||
|
||||
PLUGIN.camperTimers = PLUGIN.camperTimers or {}
|
||||
|
||||
local function IsInKillzone(pos)
|
||||
for _, zone in pairs(PLUGIN.zones) do
|
||||
if (pos:WithinAABox(zone.min, zone.max)) then
|
||||
return true, zone.name
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function PLUGIN:TickKillzoneChecks()
|
||||
local punishDelay = ix.config.Get("killzonePunishDelay", 300)
|
||||
local currentTime = CurTime()
|
||||
|
||||
for _, ply in ipairs(player.GetAll()) do
|
||||
if (!IsValid(ply) or !ply:Alive() or !ply:GetCharacter() or (ply.IsAdminMode and ply:IsAdminMode())) then
|
||||
if (self.camperTimers[ply]) then
|
||||
self.camperTimers[ply] = nil
|
||||
end
|
||||
continue
|
||||
end
|
||||
|
||||
local target = ply
|
||||
local pos = ply:GetPos()
|
||||
|
||||
-- Проверка LVS / Техники
|
||||
local veh = ply:GetVehicle()
|
||||
if (IsValid(veh)) then
|
||||
-- Для LVS ищем корень всей конструкции
|
||||
local root = veh
|
||||
if (veh.GetBaseEntity and IsValid(veh:GetBaseEntity())) then
|
||||
root = veh:GetBaseEntity()
|
||||
elseif (IsValid(veh:GetParent())) then
|
||||
root = veh:GetParent()
|
||||
end
|
||||
target = root
|
||||
pos = target:GetPos()
|
||||
end
|
||||
|
||||
local inZone, zoneName = IsInKillzone(pos)
|
||||
|
||||
if (inZone) then
|
||||
if (!self.camperTimers[target]) then
|
||||
self.camperTimers[target] = currentTime
|
||||
print("[Killzone] " .. ply:Name() .. " вошел в " .. zoneName)
|
||||
else
|
||||
local timeInZone = currentTime - self.camperTimers[target]
|
||||
|
||||
if (timeInZone >= punishDelay) then
|
||||
self:PunishTarget(target, ply)
|
||||
end
|
||||
end
|
||||
else
|
||||
if (self.camperTimers[target]) then
|
||||
print("[Killzone] " .. ply:Name() .. " покинул киллзону.")
|
||||
end
|
||||
self.camperTimers[target] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:PunishTarget(ent, ply)
|
||||
if (!ent.nextKillzoneBomb or ent.nextKillzoneBomb <= CurTime()) then
|
||||
ent.nextKillzoneBomb = CurTime() + 5
|
||||
|
||||
local targetPos = ent:GetPos()
|
||||
|
||||
-- Создаем "свист" падающей бомбы только для игрока
|
||||
if (IsValid(ply)) then
|
||||
ply:EmitSound("ambient/levels/canals/headcrab_canister_ambient.wav", 100, 100)
|
||||
end
|
||||
|
||||
-- Небольшая задержка перед ударом
|
||||
timer.Simple(0.5, function()
|
||||
if (!IsValid(ent)) then return end
|
||||
local currentPos = ent:GetPos()
|
||||
|
||||
-- Создаем мощный взрыв
|
||||
local explosion = ents.Create("env_explosion")
|
||||
if (IsValid(explosion)) then
|
||||
explosion:SetPos(currentPos)
|
||||
explosion:SetOwner(ent)
|
||||
explosion:SetKeyValue("iMagnitude", "500")
|
||||
explosion:SetKeyValue("iRadiusOverride", "300")
|
||||
explosion:Spawn()
|
||||
explosion:Fire("Explode", 0, 0)
|
||||
end
|
||||
|
||||
-- Эффект взрыва
|
||||
local effectData = EffectData()
|
||||
effectData:SetOrigin(currentPos)
|
||||
util.Effect("Explosion", effectData)
|
||||
|
||||
-- Наносим урон игроку (если это игрок)
|
||||
if (IsValid(ply) and ply:Alive()) then
|
||||
local dmg = DamageInfo()
|
||||
dmg:SetDamage(1000)
|
||||
dmg:SetDamageType(DMG_BLAST)
|
||||
dmg:SetAttacker(game.GetWorld())
|
||||
dmg:SetInflictor(game.GetWorld())
|
||||
ply:TakeDamageInfo(dmg)
|
||||
end
|
||||
|
||||
-- Если это техника, наносим ей урон отдельно
|
||||
if (ent != ply and IsValid(ent)) then
|
||||
local dmg = DamageInfo()
|
||||
dmg:SetDamage(5000)
|
||||
dmg:SetDamageType(DMG_BLAST)
|
||||
dmg:SetAttacker(game.GetWorld())
|
||||
dmg:SetInflictor(game.GetWorld())
|
||||
ent:TakeDamageInfo(dmg)
|
||||
end
|
||||
|
||||
print("[Killzone] Наказание применено к " .. (IsValid(ply) and ply:Name() or ent:GetClass()))
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
-- Запуск таймера при загрузке плагина
|
||||
if (timer.Exists("ixKillzoneTimer")) then
|
||||
timer.Remove("ixKillzoneTimer")
|
||||
end
|
||||
|
||||
timer.Create("ixKillzoneTimer", 1, 0, function()
|
||||
if (PLUGIN) then
|
||||
PLUGIN:TickKillzoneChecks()
|
||||
end
|
||||
end)
|
||||
|
||||
function PLUGIN:OnLoaded()
|
||||
-- Дублируем на случай перезагрузки плагина
|
||||
if (timer.Exists("ixKillzoneTimer")) then timer.Remove("ixKillzoneTimer") end
|
||||
timer.Create("ixKillzoneTimer", 1, 0, function()
|
||||
self:TickKillzoneChecks()
|
||||
end)
|
||||
end
|
||||
Reference in New Issue
Block a user