В чем ошибка?

Morse

Потрачен
Автор темы
436
70
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Версия MoonLoader
Другое
В чем ошибка при нажатии Поставить метку вот такая ошибка
Ошибка:
[ML] (error) CheckcordByMorse: D:\GTA 130K BY DAPO SHOW\moonloader\CheckcordByMorse.lua:48: attempt to yield across C-call boundary
stack traceback:
    [C]: in function 'wait'
    D:\GTA 130K BY DAPO SHOW\moonloader\CheckcordByMorse.lua:48: in function <D:\GTA 130K BY DAPO SHOW\moonloader\CheckcordByMorse.lua:41>
    [C]: in function 'sampProcessChatInput'
    D:\GTA 130K BY DAPO SHOW\moonloader\CheckcordByMorse.lua:72: in function 'OnDrawFrame'
    D:\GTA 130K BY DAPO SHOW\moonloader\lib\imgui.lua:1378: in function <D:\GTA 130K BY DAPO SHOW\moonloader\lib\imgui.lua:1367>
[ML] (error) CheckcordByMorse: Script died due to an error. (1A8084A4)

Lua:
script_name("CheckcordByMorse")
script_author("Morse")
script_description("Check coordinates")
script_version("1.0")

require "lib.moonloader"
local keys = require "vkeys"
local imgui = require "imgui"
local encoding = require "encoding"
encoding.default = "CP1251"
u8 = encoding.UTF8

local main_color = 0xE6E6FA
local ImVec2 = imgui.ImVec2

local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    sampAddChatMessage("[CheckCoordByMorse] Script is ready to using {FFDAB9} /chcord", main_color)
    sampAddChatMessage("[CheckCoordByMorse] Script is ready to using {FFDAB9} /chcord", main_color)
    sampAddChatMessage("[CheckCoordByMorse] Script is ready to using {FFDAB9} /chcord", main_color)

    sampRegisterChatCommand("chcord", cmd_chcord)
    sampRegisterChatCommand("setmark", cmd_setmark)

    imgui.Process = false

    while true do
        wait(0)

        if main_window_state.v == false then
            imgui.Process = false
        end
    end
end

function cmd_setmark(type, x, y, z, radius, color)
    deleteCheckpoint(marker)
    removeBlip(checkpoint)
    checkpoint = addBlipForCoord(x, y, z)
    marker = createCheckpoint(type, x, y, z, 1, 1, 1, radius)
    changeBlipColour(checkpoint, color)
    repeat
        wait(0)
        local x1, y1, z1 = getCharCoordinates(PLAYER_PED)
        until getDistanceBetweenCoords3d(x, y, z, x1, y1, z1) < radius or not doesBlipExist(checkpoint)
        deleteCheckpoint(marker)
        removeBlip(checkpoint)
        addOneOffSound(0, 0, 0, 1149)
    end

function cmd_chcord(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end

function imgui.OnDrawFrame()
    local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(400, 110), imgui.Cond.FirstUseEver)
        imgui.GetStyle().WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
imgui.Begin("CheckCordByMorse", main_window_state,  imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
imgui.SetCursorPos(imgui.ImVec2(78, 33))
imgui.InputText("", text_buffer)
imgui.SetCursorPos(imgui.ImVec2(80, 60))
if imgui.Button(u8"Поставить метку") then
    sampAddChatMessage("Метка поставлена.", main_color)
    sampProcessChatInput("/setmark " .. u8:decode(text_buffer.v))
    text_buffer.v = ""
end
imgui.SetCursorPos(imgui.ImVec2(80, 60))
if imgui.Button(u8"Сохранить координаты",  imgui.SameLine()) then
    sampAddChatMessage("Координаты сохранены.", main_color)
    text_buffer.v = ""
end
imgui.SetCursorPosX((imgui.GetWindowWidth() - 75) / 2)
imgui.Text("Script By Morse")
imgui.End()
end
 
Решение
Я тебе тут относительно изменил код, так как был треш пиздец, сейчас нормально, но все же функция которая ставит метку, ты её неправильно скопировал от куда то, переделал, сейчас всё гуд.
Lua:
script_name("CheckcordByMorse")
script_author("Morse")
script_description("Check coordinates")
script_version("1.0")

require "lib.moonloader"
local keys = require "vkeys"
local imgui = require "imgui"
local encoding = require "encoding"
encoding.default = "CP1251"
u8 = encoding.UTF8

local main_color = 0xE6E6FA
local ImVec2 = imgui.ImVec2

local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)

function main()
  if not isSampLoaded() or not isSampfuncsLoaded() then return end
  while not isSampAvailable() do wait(100)...

Morse

Потрачен
Автор темы
436
70
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.

Akionka

akionka.lua
Проверенный
742
500
напиши что исправить надо
Lua:
function cmd_setmark(type, x, y, z, radius, color)
    lua_thread.create(function()
    deleteCheckpoint(marker)
    removeBlip(checkpoint)
    checkpoint = addBlipForCoord(x, y, z)
    marker = createCheckpoint(type, x, y, z, 1, 1, 1, radius)
    changeBlipColour(checkpoint, color)
    repeat
        wait(0)
        local x1, y1, z1 = getCharCoordinates(PLAYER_PED)
        until getDistanceBetweenCoords3d(x, y, z, x1, y1, z1) < radius or not doesBlipExist(checkpoint)
        deleteCheckpoint(marker)
        removeBlip(checkpoint)
        addOneOffSound(0, 0, 0, 1149)
end)
end
вроде так, отступы сам пофиксишь, с телефона неудобно
 

Morse

Потрачен
Автор темы
436
70
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Lua:
function cmd_setmark(type, x, y, z, radius, color)
    lua_thread.create(function()
    deleteCheckpoint(marker)
    removeBlip(checkpoint)
    checkpoint = addBlipForCoord(x, y, z)
    marker = createCheckpoint(type, x, y, z, 1, 1, 1, radius)
    changeBlipColour(checkpoint, color)
    repeat
        wait(0)
        local x1, y1, z1 = getCharCoordinates(PLAYER_PED)
        until getDistanceBetweenCoords3d(x, y, z, x1, y1, z1) < radius or not doesBlipExist(checkpoint)
        deleteCheckpoint(marker)
        removeBlip(checkpoint)
        addOneOffSound(0, 0, 0, 1149)
end)
end
вроде так, отступы сам пофиксишь, с телефона неудобно
Ошибка:
[ML] (error) CheckcordByMorse: ...RIZONA GAMES\bin\Arizona\moonloader\CheckcordByMorse.lua:56: attempt to compare number with nil
stack traceback:
    ...RIZONA GAMES\bin\Arizona\moonloader\CheckcordByMorse.lua: in function <...RIZONA GAMES\bin\Arizona\moonloader\CheckcordByMorse.lua:47>
[ML] (error) CheckcordByMorse: Script died due to an error. (4131EC34)
 

Albertio

Attention! Thanks for your attention.
877
702
Я тебе тут относительно изменил код, так как был треш пиздец, сейчас нормально, но все же функция которая ставит метку, ты её неправильно скопировал от куда то, переделал, сейчас всё гуд.
Lua:
script_name("CheckcordByMorse")
script_author("Morse")
script_description("Check coordinates")
script_version("1.0")

require "lib.moonloader"
local keys = require "vkeys"
local imgui = require "imgui"
local encoding = require "encoding"
encoding.default = "CP1251"
u8 = encoding.UTF8

local main_color = 0xE6E6FA
local ImVec2 = imgui.ImVec2

local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)

function main()
  if not isSampLoaded() or not isSampfuncsLoaded() then return end
  while not isSampAvailable() do wait(100) end

  sampAddChatMessage("[CheckCoordByMorse] Script is ready to using {FFDAB9} /chcord", main_color)
  sampAddChatMessage("[CheckCoordByMorse] Script is ready to using {FFDAB9} /chcord", main_color)
  sampAddChatMessage("[CheckCoordByMorse] Script is ready to using {FFDAB9} /chcord", main_color)

  sampRegisterChatCommand("chcord", function() main_window_state.v = not main_window_state.v end)
   
  sampRegisterChatCommand("setmark", function(params)
    if not params:match("%d+ %d+ %d+ %d+ %d+ %d+") then return end
    sampAddChatMessage("Метка поставлена.", main_color)
    local type, x, y, z, radius, color = params:match("(%d+) (%d+) (%d+) (%d+) (%d+) (%d+)")
    radius = tonumber(radius)
    deleteCheckpoint(marker)
    removeBlip(checkpoint)
    checkpoint = addBlipForCoord(x, y, z)
    marker = createCheckpoint(type, x, y, z, 1, 1, 1, radius)
    changeBlipColour(checkpoint, color)
    lua_thread.create(function()
      repeat
      wait(0)
      local x1, y1, z1 = getCharCoordinates(PLAYER_PED)
        until getDistanceBetweenCoords3d(x, y, z, x1, y1, z1) < radius or not doesBlipExist(checkpoint)
        deleteCheckpoint(marker)
        removeBlip(checkpoint)
        addOneOffSound(0, 0, 0, 1149)
      end)
    end)

    while true do
      wait(0)
      imgui.Process = main_window_state.v
      if not main_window_state.v then
        imgui.ShowCursor = false
      end
    end
end

function imgui.OnDrawFrame()
if main_window_state.v then
  imgui.ShowCursor = true
  imgui.SetNextWindowPos(imgui.ImVec2(imgui.GetIO().DisplaySize.x / 2, imgui.GetIO().DisplaySize.y / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
  imgui.SetNextWindowSize(imgui.ImVec2(400, 110), imgui.Cond.FirstUseEver)
  imgui.GetStyle().WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
  imgui.Begin("CheckCordByMorse", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
  imgui.SetCursorPos(imgui.ImVec2(78, 33))
  imgui.InputText("##tbuffer", text_buffer)
  imgui.SetCursorPos(imgui.ImVec2(80, 60))
  if imgui.Button(u8"Поставить метку") then
    sampProcessChatInput("/setmark " .. u8:decode(text_buffer.v))
    text_buffer.v = ""
  end
  imgui.SetCursorPos(imgui.ImVec2(80, 60))
  if imgui.Button(u8"Сохранить координаты", imgui.SameLine()) then
    sampAddChatMessage("Координаты сохранены.", main_color)
    text_buffer.v = ""
  end
  imgui.SetCursorPosX((imgui.GetWindowWidth() - 75) / 2)
  imgui.Text("Script By Morse")
  imgui.End()
end
end