Помощь

barny0

Новичок
Автор темы
28
3
Версия MoonLoader
.026-beta
У меня есть простой скрипт который считает хп если оно меньше 40 то он автоматически вводит /healme можно ли как то сделать чтобы эта команда вводилась с рандомной задержкой от 1 секунды до 3?
 

barny0

Новичок
Автор темы
28
3
покажи код, как используешь
Lua:
require 'lib.moonloader'
local sampev = require 'lib.samp.events'
math.randomseed(os.time())

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("ah", active)
    active = false
    while true do
    wait(0)
        health = getCharHealth(PLAYER_PED)
        if health < 40 and health > 5 and active then
            wait(math.random(1000,5000))
            sampSendChat("/healme")
            wait(1000)
        end
    end
end

function active()
    if active == true then
        active = false
    else
        active = true
    end
end
 

chromiusj

Стань той переменой, которую хочешь увидеть в мире
Модератор
5,732
4,040
Lua:
require 'lib.moonloader'
local sampev = require 'lib.samp.events'
math.randomseed(os.time())

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("ah", active)
    active = false
    while true do
    wait(0)
        health = getCharHealth(PLAYER_PED)
        if health < 40 and health > 5 and active then
            wait(math.random(1000,5000))
            sampSendChat("/healme")
            wait(1000)
        end
    end
end

function active()
    if active == true then
        active = false
    else
        active = true
    end
end
Lua:
require 'lib.moonloader'
math.randomseed(os.time())

local active = false

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("ah", function ()
        active = not active
    end)
    while true do
        wait(0)
        local health = getCharHealth(PLAYER_PED)
        if health < 40 and health > 5 and active then
            wait(math.random(1000, 5000))
            sampSendChat("/healme")
            wait(1000)
        end
    end
end
у тебя переменная, и функция имеют одинаковые названия, это приводит к сбоям, в таком случае использовать другие названия переменных/нормально создавать переключение функции
1724787044056.png