- 27
- 1
Закинул вх в imgui меню, все сделал, активирую чекбокс и скрипт оффается
Lua:
local whdist = imgui.ImBool(false) -- начало
function main()
while not isSampAvailable() do wait(200) end
sampRegisterChatCommand('rehelp', function()
window.v = not window.v
end)
imgui.Process = true
while true do
wait(0)
imgui.Process = window.v
if whdist.v then
for id = 0, sampGetMaxPlayerId(true)
do
if sampIsPlayerConnected(id)
then
local exists, handle = sampGetCharHandleBySampPlayerId(id)
if exists and doesCharExist(handle) then
local oX,oY,oZ = getCharCoordinates(handle)
if isPointOnScreen(oX, oY, oZ) then
local pX, pY, pZ = getCharCoordinates(playerPed)
local wpX, wpY = convert3DCoordsToScreen(pX, pY, pZ)
local woX, woY = convert3DCoordsToScreen(oX, oY, oZ)
local dist = string.format("%.1f", getDistanceBetweenCoords3d(pX, pY, pZ, oX, oY, oZ))
res, id = sampGetPlayerIdByCharHandle(handle)
if res then
renderFontDrawText(font, " Дистанция: " .. dist .. " метров.", woX, woY, -1)
end
end
end
end
end
end
end
end
function imgui.OnDrawFrame()
if window.v then
local resX, resY = getScreenResolution()
local sizeX, sizeY = 700, 500
imgui.SetNextWindowPos(imgui.ImVec2(resX / 2 - sizeX / 2, resY / 2 - sizeY / 2), imgui.Cond.FirstUseEver)
imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
imgui.Begin(fa.ICON_FA_LAPTOP .. ' -', window)
imgui.Text('-')
imgui.Text('Author - ')
if imgui.Checkbox(u8"Дистанция к человеку", whdist) then
whdist()
end
imgui.SameLine()
imgui.Text('(?)')
if imgui.IsItemHovered() then
imgui.BeginTooltip()
imgui.Text(u8'Позволяет увидеть дистанцию игрока к вам')
imgui.EndTooltip()
end
if whdist.v then
for id = 0, sampGetMaxPlayerId(true)
do
if sampIsPlayerConnected(id)
then
local exists, handle = sampGetCharHandleBySampPlayerId(id)
if exists and doesCharExist(handle) then
local oX,oY,oZ = getCharCoordinates(handle)
if isPointOnScreen(oX, oY, oZ) then
local pX, pY, pZ = getCharCoordinates(playerPed)
local wpX, wpY = convert3DCoordsToScreen(pX, pY, pZ)
local woX, woY = convert3DCoordsToScreen(oX, oY, oZ)
local dist = string.format("%.1f", getDistanceBetweenCoords3d(pX, pY, pZ, oX, oY, oZ))
res, id = sampGetPlayerIdByCharHandle(handle)
if res then
renderFontDrawText(font, " Дистанция: " .. dist .. " метров.", woX, woY, -1)
end
end
end
end
end
end