Не уберается курсор

Annanel

Участник
Автор темы
86
8
Помогите убрать курсор мыши при активно окне imgui

Lua:
require "moonloader"
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local imgui = require('imgui')

local countdownTimer = 5 * 60 -- 5 минут в секундах
local playerBalance = 0
local startTime = 0
local isCounting = false

local window = imgui.ImBool(false)

function main()
    while not isSampAvailable() do
        wait(200)
    end

    -- Добавляем сообщение о запуске скрипта в чат
    sampAddChatMessage("{00FF00}Script Run", 0x00FF00)

    imgui.Process = false
    window.v = true  -- Показать окно при старте

    while true do
        wait(0)
        imgui.Process = window.v

        local playerID = sampGetPlayerIdByCharHandle(PLAYER_PED)
        playerBalance = getPlayerMoney()

        if not isCounting and playerBalance >= 30 then
            startTime = os.time()
            isCounting = true
        end

        if isCounting then
            local currentTime = os.time()
            local elapsedTime = currentTime - startTime
            if elapsedTime >= countdownTimer then
                stopCountdown()
            end
        end
    end
end

function stopCountdown()
    isCounting = false
end

function imgui.OnDrawFrame()
    if window.v then
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 160, 98 -- Размер окна
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 1.1 - sizeX / 2, resY / 3 - sizeY / 2), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin('Countdown Window', window)

        imgui.Text("Countdown Timer: " .. formatTime(countdownTimer))
        imgui.Text("Player Balance: $" .. playerBalance)

        if isCounting then
            imgui.Text("Countdown is running...")
        else
            imgui.Text("Waiting for balance to reach $30...")
        end

        imgui.End()
    end
end

function formatTime(seconds)
    local minutes = math.floor(seconds / 60)
    local remainingSeconds = seconds % 60
    return string.format("%02d:%02d", minutes, remainingSeconds)
end
Ещё не могу понять как сделать чтобы таймер запускал при поступление 30$ на счёт и запускался заново при получение 30$
 
Последнее редактирование:

quesada

q-team
Проверенный
852
1,163
Lua:
require "moonloader"
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local imgui = require('imgui')

local countdownTimer = 5 * 60 -- 5 минут в секундах
local playerBalance = 0
local startTime = 0
local isCounting = false

local window = imgui.ImBool(false)

function main()
    while not isSampAvailable() do
        wait(200)
    end

    -- Добавляем сообщение о запуске скрипта в чат
    sampAddChatMessage("{00FF00}Script Run", 0x00FF00)

    imgui.Process = false
    window.v = true  -- Показать окно при старте

    while true do
        wait(0)
        imgui.Process = window.v

        local playerID = sampGetPlayerIdByCharHandle(PLAYER_PED)
        playerBalance = getPlayerMoney()

        if not isCounting and playerBalance >= 30 then
            startTime = os.time()
            isCounting = true
        end

        if isCounting then
            local currentTime = os.time()
            local elapsedTime = currentTime - startTime
            if elapsedTime >= countdownTimer then
                stopCountdown()
            end
        end
    end
end

function stopCountdown()
    isCounting = false
end

function imgui.OnDrawFrame()
    if window.v then
        imgui.ShowCursor = false -- отключение курсора
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 160, 98 -- Размер окна
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 1.1 - sizeX / 2, resY / 3 - sizeY / 2), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin('Countdown Window', window)

        imgui.Text("Countdown Timer: " .. formatTime(countdownTimer))
        imgui.Text("Player Balance: $" .. playerBalance)

        if isCounting then
            imgui.Text("Countdown is running...")
        else
            imgui.Text("Waiting for balance to reach $30...")
        end

        imgui.End()
    end
end

function formatTime(seconds)
    local minutes = math.floor(seconds / 60)
    local remainingSeconds = seconds % 60
    return string.format("%02d:%02d", minutes, remainingSeconds)
end
 
  • Нравится
Реакции: Artem Kolesnikov

Annanel

Участник
Автор темы
86
8
Lua:
require "moonloader"
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local imgui = require('imgui')

local countdownTimer = 5 * 60 -- 5 минут в секундах
local playerBalance = 0
local startTime = 0
local isCounting = false

local window = imgui.ImBool(false)

function main()
    while not isSampAvailable() do
        wait(200)
    end

    -- Добавляем сообщение о запуске скрипта в чат
    sampAddChatMessage("{00FF00}Script Run", 0x00FF00)

    imgui.Process = false
    window.v = true  -- Показать окно при старте

    while true do
        wait(0)
        imgui.Process = window.v

        local playerID = sampGetPlayerIdByCharHandle(PLAYER_PED)
        playerBalance = getPlayerMoney()

        if not isCounting and playerBalance >= 30 then
            startTime = os.time()
            isCounting = true
        end

        if isCounting then
            local currentTime = os.time()
            local elapsedTime = currentTime - startTime
            if elapsedTime >= countdownTimer then
                stopCountdown()
            end
        end
    end
end

function stopCountdown()
    isCounting = false
end

function imgui.OnDrawFrame()
    if window.v then
        imgui.ShowCursor = false -- отключение курсора
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 160, 98 -- Размер окна
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 1.1 - sizeX / 2, resY / 3 - sizeY / 2), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin('Countdown Window', window)

        imgui.Text("Countdown Timer: " .. formatTime(countdownTimer))
        imgui.Text("Player Balance: $" .. playerBalance)

        if isCounting then
            imgui.Text("Countdown is running...")
        else
            imgui.Text("Waiting for balance to reach $30...")
        end

        imgui.End()
    end
end

function formatTime(seconds)
    local minutes = math.floor(seconds / 60)
    local remainingSeconds = seconds % 60
    return string.format("%02d:%02d", minutes, remainingSeconds)
end
Я пробовал почему-то не работал вариант этот, щас вписал и всё гуд

Но есть одно но курсор виден всё равно но играть можно
 

quesada

q-team
Проверенный
852
1,163
Я пробовал почему-то не работал вариант этот, щас вписал и всё гуд

Но есть одно но курсор виден всё равно но играть можно
1699305897366.png

хз нету такой проблемы
 
  • Нравится
Реакции: Artem Kolesnikov

Hinаta

Известный
783
358
не совсем понимаю, как именно это должно работать, но могу предложить такой вариант:

Lua:
function main()
    while not isSampAvailable() do
        wait(200)
    end

    playerBalance = getPlayerMoney()

    -- Добавляем сообщение о запуске скрипта в чат
    sampAddChatMessage("{00FF00}Script Run", 0x00FF00)

    imgui.Process = false
    window.v = true -- Показать окно при старте

    while true do
        wait(0)
        imgui.Process = window.v

        local playerID = sampGetPlayerIdByCharHandle(PLAYER_PED)

        if not isCounting and  (getPlayerMoney() - playerBalance) >= 30 then
            playerBalance = getPlayerMoney()
            startTime = os.time()
            isCounting = true
        end

        if isCounting then
            local currentTime = os.time()
            local elapsedTime = currentTime - startTime
            if elapsedTime >= countdownTimer then
                stopCountdown()
            end
        end
    end
end
 

Annanel

Участник
Автор темы
86
8
не совсем понимаю, как именно это должно работать, но могу предложить такой вариант:

Lua:
function main()
    while not isSampAvailable() do
        wait(200)
    end

    playerBalance = getPlayerMoney()

    -- Добавляем сообщение о запуске скрипта в чат
    sampAddChatMessage("{00FF00}Script Run", 0x00FF00)

    imgui.Process = false
    window.v = true -- Показать окно при старте

    while true do
        wait(0)
        imgui.Process = window.v

        local playerID = sampGetPlayerIdByCharHandle(PLAYER_PED)

        if not isCounting and  (getPlayerMoney() - playerBalance) >= 30 then
            playerBalance = getPlayerMoney()
            startTime = os.time()
            isCounting = true
        end

        if isCounting then
            local currentTime = os.time()
            local elapsedTime = currentTime - startTime
            if elapsedTime >= countdownTimer then
                stopCountdown()
            end
        end
    end
end
Сделаю тест когда буду дома, смотри суть такая, есть работа на которой максимум с 5 действий 30$ ЗП после идёт кд 5 минут чтобы мнова можно было выполнять работу, вот я хочу как-то сделать чтобы как только я сделал 5 действий запускался таймер отчёт 5 минут и так по новой пока не уволить с работы