ругается на wait

TimeLordRu

Известный
Автор темы
151
38
Версия MoonLoader
.026-beta
Lua:
sampRegisterChatCommand("ttt", function(arg)
    --repeat
            local x, y, z = 1019.2764892578, 2397.9187011719, 1014.7595825195
            wait(2000)
            setCharCoordinates(PLAYER_PED, 1019.2764892578, 2397.9187011719, 1014.7595825195)
            wait(4000)
            x1, y1, z1 = getCharCoordinates(PLAYER_PED, x, y, z)
            wait(2000)
            distance= math.sqrt(math.abs((x1-x)^2) + ((y1-y)^2) + ((z1-z)^2))
            sampAddChatMessage("++++ " ..distance, -1)
        --until  distance < 1000
        end)

выводит ошибку

[ML] (error) name.lua: C:\Игры\samp\moonloader\name.lua:31: attempt to yield across C-call boundary
stack traceback:
[C]: in function 'wait'
C:\Игры\samp\moonloader\name.lua:31: in function <C:\Игры\anarx2.0\moonloader\name.lua:28>
[ML] (error) name.lua: Script died due to an error. (0B973D44)
 
Последнее редактирование модератором:
Решение
Lua:
sampRegisterChatCommand("ttt", function(arg)
    --repeat
            local x, y, z = 1019.2764892578, 2397.9187011719, 1014.7595825195
            wait(2000)
            setCharCoordinates(PLAYER_PED, 1019.2764892578, 2397.9187011719, 1014.7595825195)
            wait(4000)
            x1, y1, z1 = getCharCoordinates(PLAYER_PED, x, y, z)
            wait(2000)
            distance= math.sqrt(math.abs((x1-x)^2) + ((y1-y)^2) + ((z1-z)^2))
            sampAddChatMessage("++++ " ..distance, -1)
        --until  distance < 1000
        end)

выводит ошибку
Lua:
sampRegisterChatCommand("ttt", function(arg)
    --repeat
            lua_thread.create(function()
                local x, y, z = 1019.2764892578, 2397.9187011719...

nomio

Известный
550
208
Lua:
sampRegisterChatCommand("ttt", function(arg)
    --repeat
            local x, y, z = 1019.2764892578, 2397.9187011719, 1014.7595825195
            wait(2000)
            setCharCoordinates(PLAYER_PED, 1019.2764892578, 2397.9187011719, 1014.7595825195)
            wait(4000)
            x1, y1, z1 = getCharCoordinates(PLAYER_PED, x, y, z)
            wait(2000)
            distance= math.sqrt(math.abs((x1-x)^2) + ((y1-y)^2) + ((z1-z)^2))
            sampAddChatMessage("++++ " ..distance, -1)
        --until  distance < 1000
        end)

выводит ошибку
Lua:
sampRegisterChatCommand("ttt", function(arg)
    --repeat
            lua_thread.create(function()
                local x, y, z = 1019.2764892578, 2397.9187011719, 1014.7595825195
                wait(2000)
                setCharCoordinates(PLAYER_PED, 1019.2764892578, 2397.9187011719, 1014.7595825195)
                wait(4000)
                x1, y1, z1 = getCharCoordinates(PLAYER_PED, x, y, z)
                wait(2000)
                distance= math.sqrt(math.abs((x1-x)^2) + ((y1-y)^2) + ((z1-z)^2))
                sampAddChatMessage("++++ " ..distance, -1)
            end)
        --until  distance < 1000
        end)