local imgui = require 'mimgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local renderWindow = imgui.new.bool(true)
imgui.OnInitialize(function()
imgui.GetIO().IniFilename = nil
end)
local newFrame = imgui.OnFrame(
function() return renderWindow[0] end,
function()
local resX, resY = getScreenResolution()
local sizeX, sizeY = 300, 400
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)
if imgui.Begin(u8'Игроки рядом', renderWindow) then
local myId = select(2, sampGetPlayerIdByCharHandle(PLAYER_PED))
local myX, myY, myZ = getCharCoordinates(PLAYER_PED)
for i = 0, sampGetMaxPlayerId() do
if sampIsPlayerConnected(i) and i ~= myId then
local result, ped = sampGetCharHandleBySampPlayerId(i)
if result and doesCharExist(ped) then
local x, y, z = getCharCoordinates(ped)
local dx, dy, dz = x - myX, y - myY, z - myZ
local dist = math.sqrt(dx*dx + dy*dy + dz*dz)
if dist < 50.0 then
local name = sampGetPlayerNickname(i)
imgui.BulletText(u8(string.format("%s (ID: %d) — %.1f м", name, i, dist)))
end
end
end
end
imgui.End()
end
end
)
function main()
while not isSampAvailable() do wait(0) end
sampRegisterChatCommand('nearby', function()
renderWindow[0] = not renderWindow[0]
end)
wait(-1)
end