помогите в луа

rertlop

Участник
Автор темы
47
3
Версия MoonLoader
Другое
Доброво времени суток, не могу понять почему не работает скрипт, подскажите пожалуйста
Код:
local sampev = require "lib.samp.events"

local power = false

function main()
    repeat wait(0) until isSampAvailable()

    sampRegisterChatCommand('pl', pl_cmd()
    sampRegisterChatCommand('iclose', iclose_cmd()
   
        bool = not bool
        sampAddChatMessage(bool and ('{F1C232}Скрипт включен.') or ('{F1C232}Скрипт выключен.'), -1)
    end)
end
   
function pl_cmd()
    while true do wait(0)
        if bool then
            for i = 0, 2048 do
                if sampIs3dTextDefined(i) then
                    local pp = {sampGet3dTextInfoById(i)}
                    if pp[1]:match('Наркотики') then
                        if not sampIsCursorActive() then
                            setVirtualKeyDown(18, true)
                            wait(100)
                            setVirtualKeyDown(13, true)
                            wait(100)
                            setVirtualKeyDown(18, false)
                            wait(100)
                            setVirtualKeyDown(13, false)
                            wait(100)
                            setVirtualKeyDown(13, false)
                            wait(100)
                            setVirtualKeyDown(13, false)
                            wait(100)
                            setVirtualKeyDown(13, false)
                            wait(100)
                        end
                    end
                end
            end
        end
    end
end

function iclose_cmd()
    power = not power
     while true do
        wait(1000)
        if power then
            sampSendClickTextdraw(2083)
            wait(1000)
        end
    end
end
 

shibaTaidjy

Известный
446
157
попробуй
LUA:
local sampev = require "lib.samp.events"

local power = false

function main()
    repeat wait(0) until isSampAvailable()

    sampRegisterChatCommand('pl', pl_cmd)
    sampRegisterChatCommand('iclose', function()
        iclose_cmd()
        bool = not bool
        sampAddChatMessage(bool and ('{F1C232}Скрипт включен.') or ('{F1C232}Скрипт выключен.'), -1)
    end)
    wait(-1)
end
 
function pl_cmd()
    lua_thread.create(function()
        while true do wait(0)
            if bool then
                for i = 0, 2048 do
                    if sampIs3dTextDefined(i) then
                        local pp = {sampGet3dTextInfoById(i)}
                        if pp[1]:match('Наркотики') then
                            if not sampIsCursorActive() then
                                setVirtualKeyDown(18, true)
                                wait(100)
                                setVirtualKeyDown(13, true)
                                wait(100)
                                setVirtualKeyDown(18, false)
                                wait(100)
                                setVirtualKeyDown(13, false)
                                wait(100)
                                setVirtualKeyDown(13, false)
                                wait(100)
                                setVirtualKeyDown(13, false)
                                wait(100)
                                setVirtualKeyDown(13, false)
                                wait(100)
                            end
                        end
                    end
                end
            end
        end
    end)
end

function iclose_cmd()
    lua_thread.create(function()
        power = not power
        while true do
            wait(1000)
            if power then
                sampSendClickTextdraw(2083)
                wait(1000)
            end
        end
    end)
end
update:
посмотри видео про потоки также
 
Последнее редактирование:
  • Нравится
Реакции: YarikVL