ping point

juki

Участник
Автор темы
62
12
дернул формулу с клео пинг поинта, но бокс рисует в жопе
CLEO:
:PingPoint_419
6@, 7@, 8@ = get_char_coordinates 2@
9@ = samp_get_player_ping 1@
11@ = samp_get_player_id $scplayer
10@ = samp_get_player_ping 11@
add_int_lvar_to_int_lvar 9@ += 10@
cset_lvar_float_to_lvar_int 10@ =# 9@
print_formatted_now "%d: %d" {time} 100 {args} 1@ 9@
12@ = 17.0
12@ /= 360.0
mult_float_lvar_by_float_lvar 3@ *= 12@
mult_float_lvar_by_float_lvar 4@ *= 12@
mult_float_lvar_by_float_lvar 5@ *= 12@
mult_float_lvar_by_float_lvar 3@ *= 10@
mult_float_lvar_by_float_lvar 4@ *= 10@
mult_float_lvar_by_float_lvar 5@ *= 10@
add_float_lvar_to_float_lvar 6@ += 3@
add_float_lvar_to_float_lvar 7@ += 4@
add_float_lvar_to_float_lvar 8@ += 5@
cleo_call @PingPoint_694 {numArgs} 3 {args} 6@ 7@ 8@ 6@ 7@
draw_rect 6@ {y} 7@ {width} 10.0 {height} 10.0 {r} 0 {g} 50 {b} 155 {a} 200
draw_rect 6@ {y} 7@ {width} 3.0 {height} 3.0 {r} 255 {g} 0 {b} 0 {a} 200
Lua:
local imgui = require("mimgui")

local frame = imgui.OnFrame(
    function() return true end,
    function(player)
        player.HideCursor = true
        local dl = imgui.GetBackgroundDrawList()

        for i, v in ipairs(getAllChars()) do
            if doesCharExist(v) and isCharOnScreen(v) then
                local playerId = select(2, sampGetPlayerIdByCharHandle(v))
                local playerPedId = select(2, sampGetPlayerIdByCharHandle(PLAYER_PED))
                        
                local pX, pY, pZ = getCharCoordinates(v)
                local sX, sY, sZ = 0, 0, 0

                if isCharInAnyCar(v) then
                    sX, sY, sZ = getCarSpeedVector(storeCarCharIsInNoSave(v))
                else
                    sX, sY, sZ = getCharVelocity(v)
                end

                local ping = sampGetPlayerPing(playerId) + sampGetPlayerPing(playerPedId)
                
                local mult = 17.0 / 360.0
                
                pX = pX + sX * mult * ping
                pY = pY + sY * mult * ping
                pZ = pZ + sZ * mult * ping
                
                local x, y = convert3DCoordsToScreen(pX, pY, pZ)
                dl:AddRectFilled(imgui.ImVec2(x - 10, y - 10), imgui.ImVec2(x + 10, y + 10), 0xC89B3200)
                dl:AddRectFilled(imgui.ImVec2(x - 3, y - 3), imgui.ImVec2(x + 3, y + 3), 0xC80000FF)
            end
        end
    end
)
 
Решение
а где должно? выше переписанный вариант, а снизу на клео, наверное так правильно будет, правда с размерами недопер
1783551763039.png

Lua:
local ffi = require("ffi")

local active = false

local function readFloat(addr)
    return ffi.cast("float*", addr)[0]
end

function main()
    while not isSampAvailable() do wait(0) end
    while true do
        wait(0)
        if wasKeyPressed(0xBB) then
            active = true
        elseif wasKeyPressed(0xBD) then
            active = false
        end
        if active then
            local bromo, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
            if bromo then
                local maxPlayerId = sampGetMaxPlayerId(true)
                for playerId = 0, maxPlayerId do
                    if...

chromiusj

Известный
Модератор
6,053
4,400
а где должно? выше переписанный вариант, а снизу на клео, наверное так правильно будет, правда с размерами недопер
1783551763039.png

Lua:
local ffi = require("ffi")

local active = false

local function readFloat(addr)
    return ffi.cast("float*", addr)[0]
end

function main()
    while not isSampAvailable() do wait(0) end
    while true do
        wait(0)
        if wasKeyPressed(0xBB) then
            active = true
        elseif wasKeyPressed(0xBD) then
            active = false
        end
        if active then
            local bromo, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
            if bromo then
                local maxPlayerId = sampGetMaxPlayerId(true)
                for playerId = 0, maxPlayerId do
                    if sampIsPlayerConnected(playerId) then
                        local result, ped = sampGetCharHandleBySampPlayerId(playerId)
                        if result and ped ~= PLAYER_PED and doesCharExist(ped) and not isCharDead(ped) and isCharOnScreen(ped) then
                            local x, y, z = getCharCoordinates(ped)
                            local vx, vy, vz
                            if not isCharInAnyCar(ped) then
                                local ptr = getCharPointer(ped)
                                vx = readFloat(ptr + 68)
                                vy = readFloat(ptr + 72)
                                vz = readFloat(ptr + 76)
                            else
                                local car = storeCarCharIsInNoSave(ped)
                                local ptr = getCarPointer(car)
                                vx = readFloat(ptr + 68)
                                vy = readFloat(ptr + 72)
                                vz = readFloat(ptr + 76)
                            end
                            local totalPing = sampGetPlayerPing(playerId) + sampGetPlayerPing(id)
                            local mult = (17.0 / 360.0) * totalPing
                            local px = x + vx * mult
                            local py = y + vy * mult
                            local pz = z + vz * mult
                            local visible, sx, sy, sz = convert3DCoordsToScreenEx(px, py, pz)
                            if visible and sz > 0 then
                                renderDrawBox(sx - 7, sy - 7, 14, 14, 0xC800329B)
                                renderDrawBox(sx - 2.5, sy - 2.5, 5, 5, 0xC8FF0000)
                            end
                        end
                    end
                end
            end
        end
    end
end
 
  • Нравится
Реакции: juki