attempt to yield across C-call boundary

killerson

Новичок
Автор темы
27
0
Версия MoonLoader
.026-beta
help me plz >.<
[08:49:54.945928] (error) indicator.lua: D:\GTA\moonloader\indicator.lua:2: attempt to yield across C-call boundary
stack traceback:
[C]: in function 'wait'
D:\GTA\moonloader\indicator.lua:2: in main chunk

indiactor:
while true do
        wait(0)  
        local cam_x, cam_y, cam_z = getActiveCameraCoordinates()
        local width, heigth = convertGameScreenCoordsToWindowScreenCoords(339.1, 179.1)
        local cross_x, cross_y, cross_z = convertScreenCoordsToWorld3D(width, heigth, 100)
        local result, pointer = processLineOfSight(cam_x, cam_y, cam_z, cross_x, cross_y, cross_z, false, false, true, false, false, false, false)
        if result then
            if isLineOfSightClear(cam_x, cam_y, cam_z, pointer.pos[1], pointer.pos[2], pointer.pos[3], true, true, false, true, true) then
                if pointer.entityType == 3 then
                    if getCharPointerHandle(pointer.entity) ~= playerPed then
                        changeCrosshairColor(0x00FF00FF)
                    end
                end
            end
        end
end
 

Iskon

Участник
99
16
Это происходит из-за того, что ты пытаешься вызвать функцию wait() не в теле основного потока main.

Ты можешь свой цикл засунуть в поток, и все будет работать.


Код:
lua_thread.create(function ()
while true do
        wait(0) 
        local cam_x, cam_y, cam_z = getActiveCameraCoordinates()
        local width, heigth = convertGameScreenCoordsToWindowScreenCoords(339.1, 179.1)
        local cross_x, cross_y, cross_z = convertScreenCoordsToWorld3D(width, heigth, 100)
        local result, pointer = processLineOfSight(cam_x, cam_y, cam_z, cross_x, cross_y, cross_z, false, false, true, false, false, false, false)
        if result then
            if isLineOfSightClear(cam_x, cam_y, cam_z, pointer.pos[1], pointer.pos[2], pointer.pos[3], true, true, false, true, true) then
                if pointer.entityType == 3 then
                    if getCharPointerHandle(pointer.entity) ~= playerPed then
                        changeCrosshairColor(0x00FF00FF)
                    end
                end
            end
       end
end
end)
 

killerson

Новичок
Автор темы
27
0
Это происходит из-за того, что ты пытаешься вызвать функцию wait() не в теле основного потока main.

Ты можешь свой цикл засунуть в поток, и все будет работать.


Код:
lua_thread.create(function ()
while true do
        wait(0)
        local cam_x, cam_y, cam_z = getActiveCameraCoordinates()
        local width, heigth = convertGameScreenCoordsToWindowScreenCoords(339.1, 179.1)
        local cross_x, cross_y, cross_z = convertScreenCoordsToWorld3D(width, heigth, 100)
        local result, pointer = processLineOfSight(cam_x, cam_y, cam_z, cross_x, cross_y, cross_z, false, false, true, false, false, false, false)
        if result then
            if isLineOfSightClear(cam_x, cam_y, cam_z, pointer.pos[1], pointer.pos[2], pointer.pos[3], true, true, false, true, true) then
                if pointer.entityType == 3 then
                    if getCharPointerHandle(pointer.entity) ~= playerPed then
                        changeCrosshairColor(0x00FF00FF)
                    end
                end
            end
       end
end
end)
теперь выдает эту ошибку:
[02:05:10.570435] (error) indicator.lua: D:\GTA\moonloader\indicator.lua:12: attempt to call global 'changeCrosshairColor' (a nil value)
stack traceback:
D:\GTA\moonloader\indicator.lua: in function <D:\GTA\moonloader\indicator.lua:1>
[02:05:10.570435] (error) indicator.lua: Script died due to an error. (0D1848BC)
 

MrDorlik

Известный
977
392
теперь выдает эту ошибку:
[02:05:10.570435] (error) indicator.lua: D:\GTA\moonloader\indicator.lua:12: attempt to call global 'changeCrosshairColor' (a nil value)
stack traceback:
D:\GTA\moonloader\indicator.lua: in function <D:\GTA\moonloader\indicator.lua:1>
[02:05:10.570435] (error) indicator.lua: Script died due to an error. (0D1848BC)
функция changeCrosshairColor не объявлена
 

MLycoris

Режим чтения
Проверенный
1,821
1,860
если ты не знаешь что такое функция, как ты код пишешь вообще
та он эту фигню скопировал и не знает что с ней делать
 
  • Нравится
Реакции: killerson

MrDorlik

Известный
977
392
help me plz >.<
[08:49:54.945928] (error) indicator.lua: D:\GTA\moonloader\indicator.lua:2: attempt to yield across C-call boundary
stack traceback:
[C]: in function 'wait'
D:\GTA\moonloader\indicator.lua:2: in main chunk

indiactor:
while true do
        wait(0)
        local cam_x, cam_y, cam_z = getActiveCameraCoordinates()
        local width, heigth = convertGameScreenCoordsToWindowScreenCoords(339.1, 179.1)
        local cross_x, cross_y, cross_z = convertScreenCoordsToWorld3D(width, heigth, 100)
        local result, pointer = processLineOfSight(cam_x, cam_y, cam_z, cross_x, cross_y, cross_z, false, false, true, false, false, false, false)
        if result then
            if isLineOfSightClear(cam_x, cam_y, cam_z, pointer.pos[1], pointer.pos[2], pointer.pos[3], true, true, false, true, true) then
                if pointer.entityType == 3 then
                    if getCharPointerHandle(pointer.entity) ~= playerPed then
                        changeCrosshairColor(0x00FF00FF)
                    end
                end
            end
        end
end
Lua:
local memory = require "memory"

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(0) end
    while true do
        wait(0)
        local cam_x, cam_y, cam_z = getActiveCameraCoordinates()
        local width, heigth = convertGameScreenCoordsToWindowScreenCoords(339.1, 179.1)
        local cross_x, cross_y, cross_z = convertScreenCoordsToWorld3D(width, heigth, 100)
        local result, pointer = processLineOfSight(cam_x, cam_y, cam_z, cross_x, cross_y, cross_z, false, false, true, false, false, false, false)
        if result then
            if isLineOfSightClear(cam_x, cam_y, cam_z, pointer.pos[1], pointer.pos[2], pointer.pos[3], true, true, false, true, true) then
                if pointer.entityType == 3 then
                    if getCharPointerHandle(pointer.entity) ~= playerPed then
                        changeCrosshairColor(0xFF0000FF)
                    end
                end
            end
        else
            changeCrosshairColor(0xFFFFFFFF)
        end
    end
end

function changeCrosshairColor(rgba)
    local r = bit.band(bit.rshift(rgba, 24), 0xFF)
    local g = bit.band(bit.rshift(rgba, 16), 0xFF)
    local b = bit.band(bit.rshift(rgba, 8), 0xFF)
    local a = bit.band(rgba, 0xFF)

    memory.setuint8(0x58E301, r, true)
    memory.setuint8(0x58E3DA, r, true)
    memory.setuint8(0x58E433, r, true)
    memory.setuint8(0x58E47C, r, true)

    memory.setuint8(0x58E2F6, g, true)
    memory.setuint8(0x58E3D1, g, true)
    memory.setuint8(0x58E42A, g, true)
    memory.setuint8(0x58E473, g, true)

    memory.setuint8(0x58E2F1, b, true)
    memory.setuint8(0x58E3C8, b, true)
    memory.setuint8(0x58E425, b, true)
    memory.setuint8(0x58E466, b, true)

    memory.setuint8(0x58E2EC, a, true)
    memory.setuint8(0x58E3BF, a, true)
    memory.setuint8(0x58E420, a, true)
    memory.setuint8(0x58E461, a, true)
end
 
Последнее редактирование:
  • Нравится
Реакции: killerson