В чем проблема? У меня какая то ошибка в строке с запуском потока

Malenko

Новичок
Автор темы
18
3
Версия MoonLoader
.026-beta
Lua:
require "lib.moonloader"
local keys = require "vkeys"
local imgui = require "imgui"
local sampev = require 'lib.samp.events'
local encoding = require "encoding"
encoding.default = 'CP1251'
u8 = encoding.UTF8

local tag = "[AutoSobeska]:"
local label = 0
local main_color = 0x5A90CE
local main_color_text = "{5A90CE}"
local white_color = "{FFFFFF}"
local gov_time = 0
local real_time = 0
local govka = 0

thr = lua_thread.create_suspended(fartumast)


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

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

    sampRegisterChatCommand('autosobes', cmd_imgui)
    sampRegisterChatCommand('timesk', cmd_timesk)

    imgui.Process = false

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

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

function imgui.OnDrawFrame()
    imgui.Begin("AutoSobeska", main_window_state)
    imgui.InputText(u8'Тут час и минута говки в таком формате: 2359', text_buffer)
    imgui.Text(text_buffer.v)
    if imgui.Button(u8"Забить говку") then
        govka = 1
        --gov_hour = string.sub(text_buffer.v, 1, 2)
        --gov_minute = string.sub(text_buffer.v, 3, 4)
        gov_time = text_buffer.v
        real_time = os.date("%H%M")
        while govka == 1 do
        thr:run()
    end
    end
    imgui.End()
end
function cmd_timesk()
    sampAddChatMessage(os.date("%H"), -1)
end
function fartumast()
        if real_time < gov_time then
            sampAddChatMessage('bebra', -1)
            wait(10)
    end
end
 

thx killa

Известный
15
8
Lua:
require "lib.moonloader"
local keys = require "vkeys"
local imgui = require "imgui"
local sampev = require 'lib.samp.events'
local encoding = require "encoding"
encoding.default = 'CP1251'
u8 = encoding.UTF8

local tag = "[AutoSobeska]:"
local label = 0
local main_color = 0x5A90CE
local main_color_text = "{5A90CE}"
local white_color = "{FFFFFF}"
local gov_time = 0
local real_time = 0
local govka = 0


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

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

    thread = lua_thread.create_suspended(thread_function)

    sampRegisterChatCommand('autosobes', cmd_imgui)
    sampRegisterChatCommand('timesk', cmd_timesk)


    imgui.Process = false

    while true do
        wait(0)
        if main_window_state.v == false then
            imgui.Process = false
        end
        if govka == 1 then
            thread:run('sobeska')
        end
    end
end

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

function imgui.OnDrawFrame()
    imgui.Begin("AutoSobeska", main_window_state)
    imgui.InputText(u8'Тут час и минута говки в таком формате: 2359', text_buffer)
    imgui.Text(text_buffer.v)
    if imgui.Button(u8"Забить говку") then
        govka = 1
        --gov_hour = string.sub(text_buffer.v, 1, 2)
        --gov_minute = string.sub(text_buffer.v, 3, 4)
        gov_time = text_buffer.v
        real_time = os.date("%H%M")
    end
    imgui.End()
end
function cmd_timesk()
    sampAddChatMessage(os.date("%H"), -1)
end

function thread_function(option)
    if option == 'sobeska' then
        if real_time < gov_time then
                sampAddChatMessage('bebra', -1)
                wait(10)
        end
    end
end

Сделал рабочим. Но как будто бы нужно научить этот скрипт как минимум останавливаться, но это не точно :d
Подробнее о циклах посмотри у TheChampGuess на YT.
 

Malenko

Новичок
Автор темы
18
3
Lua:
require "lib.moonloader"
local keys = require "vkeys"
local imgui = require "imgui"
local sampev = require 'lib.samp.events'
local encoding = require "encoding"
encoding.default = 'CP1251'
u8 = encoding.UTF8

local tag = "[AutoSobeska]:"
local label = 0
local main_color = 0x5A90CE
local main_color_text = "{5A90CE}"
local white_color = "{FFFFFF}"
local gov_time = 0
local real_time = 0
local govka = 0


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

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

    thread = lua_thread.create_suspended(thread_function)

    sampRegisterChatCommand('autosobes', cmd_imgui)
    sampRegisterChatCommand('timesk', cmd_timesk)


    imgui.Process = false

    while true do
        wait(0)
        if main_window_state.v == false then
            imgui.Process = false
        end
        if govka == 1 then
            thread:run('sobeska')
        end
    end
end

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

function imgui.OnDrawFrame()
    imgui.Begin("AutoSobeska", main_window_state)
    imgui.InputText(u8'Тут час и минута говки в таком формате: 2359', text_buffer)
    imgui.Text(text_buffer.v)
    if imgui.Button(u8"Забить говку") then
        govka = 1
        --gov_hour = string.sub(text_buffer.v, 1, 2)
        --gov_minute = string.sub(text_buffer.v, 3, 4)
        gov_time = text_buffer.v
        real_time = os.date("%H%M")
    end
    imgui.End()
end
function cmd_timesk()
    sampAddChatMessage(os.date("%H"), -1)
end

function thread_function(option)
    if option == 'sobeska' then
        if real_time < gov_time then
                sampAddChatMessage('bebra', -1)
                wait(10)
        end
    end
end

Сделал рабочим. Но как будто бы нужно научить этот скрипт как минимум останавливаться, но это не точно :d
Подробнее о циклах посмотри у TheChampGuess на YT.
Сама цель скрипта в определенное время вывести в чат сообщение, а не флудить до определенного времени