- 338
- 67
- Версия MoonLoader
- Другое
Драсте, не могу понять почему над другими игроками не отображаются кружки. Если убираю проверку в зоне стрима то кружочки тупо по всей карте
Lua:
local imgui = require("mimgui")
local ev = require("samp.events")
local new = imgui.new
local renderWindow = new.bool(true)
local newFrame = imgui.OnFrame(
function() return renderWindow[0] end,
function(player)
local resX, resY = getScreenResolution()
local sizeX, sizeY = 300, 300
imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
imgui.Begin('Main Window', renderWindow, imgui.WindowFlags.NoBackground + imgui.WindowFlags.NoMove + imgui.WindowFlags.NoDecoration)
local x,y,z = getCharCoordinates(PLAYER_PED)
local wx,wy = convert3DCoordsToScreen(x,y,z)
local dl = imgui.GetBackgroundDrawList();
imgui.CircleProcessBar(dl, getCharHealth(PLAYER_PED), 0xFFF0000, imgui.ImVec2(wx, wy - 350), 40, 100);
for k, v in pairs(getAllChars()) do
local dl = imgui.GetBackgroundDrawList();
local px, py, pz = getCharCoordinates(v)
-- Проверяем, находится ли персонаж в зоне стрима
if isInStreamingZone(px, py, pz) then
local ex, ey = convert3DCoordsToScreen(px, py, pz)
imgui.CircleProcessBar(dl, getCharHealth(v), 0xFFFF0000, imgui.ImVec2(ex, ey - 350), 40, 100);
end
end
imgui.End()
end
)
function main()
sampRegisterChatCommand('mimgui', function()
renderWindow[0] = not renderWindow[0]
end)
end
function imgui.CircleProcessBar(dl, value, color, center, radius, num_segments)
if value > 100.0 then
value = 100.0;
elseif value < 0.0 then
value = 0.0;
end
local segment_rad = 2 * (value / 31.4) / num_segments;
dl:AddCircleFilled(center, radius, 0xCC101010, num_segments);
dl:AddCircle(center, radius, 0xFF757371, num_segments, 4);
for i = 0, num_segments do
local a = imgui.ImVec2(center.x - radius * math.sin(segment_rad * i),
center.y - radius * math.cos(segment_rad * i));
local b = imgui.ImVec2(center.x - radius * math.sin(segment_rad * (i + 1)),
center.y - radius * math.cos(segment_rad * (i + 1)));
dl:AddLine(a, b, color, 4);
end
end
function isInStreamingZone(px, py, pz)
-- Задайте границы зоны стрима
local zoneMinX, zoneMaxX = -500, 500
local zoneMinY, zoneMaxY = -500, 500
local zoneMinZ, zoneMaxZ = 0, 100
return px >= zoneMinX and px <= zoneMaxX and
py >= zoneMinY and py <= zoneMaxY and
pz >= zoneMinZ and pz <= zoneMaxZ
end
Последнее редактирование: