Можно-ли как то сделать проверку на игрока в красной зоне? Например по диагонали точек 1-3 или 2-4, которые указаны на скриншоте.
Решение - добавить 4 точки реализовать создание искусственного квадрата. Ниже приведу пример с отключением урона в квадрате
local squares = {
{
{x = -1647.968750, y = -1040.031250, z = 64.031250},
{x = -1647.968750, y = -1327.968750, z = 64.031250},
{x = -1281.448730, y = -1327.988403, z = 64.031250},
{x = -1287.838379, y = -1040.031250, z = 64.031250}
},
-- Add more squares as needed
}
-- Function to check if a point is inside a square
local function isPointInSquare(point, square)
local minX, maxX, minY, maxY = math.huge, -math.huge, math.huge, -math.huge
for _, p in ipairs(square) do
minX, maxX = math.min(minX, p.x), math.max(maxX, p.x)
minY, maxY = math.min(minY, p.y), math.max(maxY, p.y)
end
return point.x >= minX and point.x <= maxX and point.y >= minY and point.y <= maxY
end
hook.Add( "EntityTakeDamage", "EntityDamageExample", function( target, dmginfo )
if not target:IsPlayer() then return end
local playerPos = Vector(target:GetPos())
for _, square in ipairs(squares) do
if isPointInSquare(playerPos, square) then
--print("Player is in the safe zone!")
return true -- Prevent the damage from being applied
end
end
end )