help with the function

Runbu73

Участник
Автор темы
123
4
if vxfullped.v then
local pos = {GetBodyPartCoordinates(8, handlePed)}
local x1, y1 = convert3DCoordsToScreen(pos[1], pos[2], pos[3])
local x2, y2 = convert3DCoordsToScreen(pos[1], pos[2], pos[3]) -- NEW variant
local _, id = sampGetPlayerIdByCharHandle(handlePed)
local nick = sampGetPlayerNickname(id)
renderFontDrawText(font, nick.." | ID ["..id.."]" , x2, y2 - 50, color, -1)
end

error:
[ML] (error) Scarllet Rage: ...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:926: attempt to call global 'GetBodyPartCoordinates' (a nil value)
stack traceback:
...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua: in function 'whiledo'
...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:403: in function <...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:245>
[ML] (error) Scarllet Rage: Script died due to an error. (266D4D74)

please help me correct the function or send me the correct one

Ícone Verificada pela comunidade
 

chromiusj

прогресс невозможен без пива
Модератор
5,558
3,870
Lua:
local ffi = require "ffi"
local getBonePosition = ffi.cast("int (__thiscall*)(void*, float*, int, bool)", 0x5E4280)
local font_flag = require('moonloader').font_flag
local my_font = renderCreateFont('Verdana', 12, font_flag.BOLD + font_flag.SHADOW)
function main()
    while not isSampAvailable() do wait(0) end
        
    while true do
        wait(0)
        local res, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        if res then
            local nick = sampGetPlayerNickname(id)
            local coords = {getBodyPartCoordinates(8,PLAYER_PED)}
            local x1,y1 = convert3DCoordsToScreen(coords[1],coords[2],coords[3])
            renderFontDrawText(my_font, nick.." ["..id.."]", x1, y1, 0xFFFFFFFF)
        end
    end
end
function getBodyPartCoordinates(id, handle)
  local pedptr = getCharPointer(handle)
  local vec = ffi.new("float[3]")
  getBonePosition(ffi.cast("void*", pedptr), vec, id, true)
  return vec[0], vec[1], vec[2]
end
1708381852878.png

maybe the problem was that you either didn’t insert the function, or it wasn’t visible in the script area, and the block didn’t see it
I am attaching my solution to your problem, you just need to add your imgui interface
 

Runbu73

Участник
Автор темы
123
4
Lua:
local ffi = require "ffi"
local getBonePosition = ffi.cast("int (__thiscall*)(void*, float*, int, bool)", 0x5E4280)
local font_flag = require('moonloader').font_flag
local my_font = renderCreateFont('Verdana', 12, font_flag.BOLD + font_flag.SHADOW)
function main()
    while not isSampAvailable() do wait(0) end
       
    while true do
        wait(0)
        local res, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        if res then
            local nick = sampGetPlayerNickname(id)
            local coords = {getBodyPartCoordinates(8,PLAYER_PED)}
            local x1,y1 = convert3DCoordsToScreen(coords[1],coords[2],coords[3])
            renderFontDrawText(my_font, nick.." ["..id.."]", x1, y1, 0xFFFFFFFF)
        end
    end
end
function getBodyPartCoordinates(id, handle)
  local pedptr = getCharPointer(handle)
  local vec = ffi.new("float[3]")
  getBonePosition(ffi.cast("void*", pedptr), vec, id, true)
  return vec[0], vec[1], vec[2]
end
Посмотреть вложение 232547
maybe the problem was that you either didn’t insert the function, or it wasn’t visible in the script area, and the block didn’t see it
I am attaching my solution to your problem, you just need to add your imgui interface
[ML] (error) Scarllet Rage: cannot resume non-suspended coroutine
stack traceback:
[C]: in function 'renderFontDrawText'
...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:2339: in function <...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:2329>
[ML] (error) Scarllet Rage: Script died due to an error. (266F7A94)
 

Vintik

Через тернии к звёздам
Проверенный
1,526
1,010
[ML] (error) Scarllet Rage: cannot resume non-suspended coroutine
stack traceback:
[C]: in function 'renderFontDrawText'
...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:2339: in function <...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:2329>
[ML] (error) Scarllet Rage: Script died due to an error. (266F7A94)
покажи полный код скрипта, думаю возможно в нём проблема