Colldown в бесконечном цикле

kickflip228

Участник
Автор темы
83
5
Версия MoonLoader
.027.0-preview
Как сделать так чтобы этой командой не спамило, а выполняло с кулдауном в 1 секунду?
Lua:
function main()
  ffi.C.GetWindowRect(ffi.C.GetActiveWindow(), rcClip);
  ffi.C.ClipCursor(rcClip);
  while true do
    wait(0)
    if not sampIsChatInputActive() then
    hp = getCharHealth(PLAYER_PED)
    if isKeyJustPressed(18) then
        sampSendChat('/usedrugs 8')
        setGameKeyState(21, 255)
        setGameKeyState(21, 0)
    elseif hp < 160 then
        sampSendChat('/usedrugs 8')
        wait(50)
        setGameKeyState(21, 255)
        setGameKeyState(21, 0)
        end
    end
    end
end

Я про
elseif hp < 160 then
sampSendChat('/usedrugs 8')
 
Решение
Lua:
function main()
  ffi.C.GetWindowRect(ffi.C.GetActiveWindow(), rcClip);
  ffi.C.ClipCursor(rcClip);
  while true do
    wait(0)
    local hp = getCharHealth(PLAYER_PED)
    if not sampIsChatInputActive() and not sampIsDialogActive() and not isSampfuncsConsoleActive() and isKeyJustPressed(18) then
        sampSendChat('/usedrugs 8')
        setGameKeyState(21, 255)
        setGameKeyState(21, 0)
    elseif hp < 160 then
        sampSendChat('/usedrugs 8')
        wait(50)
        setGameKeyState(21, 255)
        setGameKeyState(21, 0)
        while getCharHealth(PLAYER_PED) >= 150 do wait(0) end
    end
end

accord-

Потрачен
437
79
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
1658759586668.png


если правильно понял тебя
 

#Northn

Police Helper «Reborn» — уже ШЕСТЬ лет!
Всефорумный модератор
2,639
2,489
Lua:
function main()
  ffi.C.GetWindowRect(ffi.C.GetActiveWindow(), rcClip);
  ffi.C.ClipCursor(rcClip);
  while true do
    wait(0)
    local hp = getCharHealth(PLAYER_PED)
    if not sampIsChatInputActive() and not sampIsDialogActive() and not isSampfuncsConsoleActive() and isKeyJustPressed(18) then
        sampSendChat('/usedrugs 8')
        setGameKeyState(21, 255)
        setGameKeyState(21, 0)
    elseif hp < 160 then
        sampSendChat('/usedrugs 8')
        wait(50)
        setGameKeyState(21, 255)
        setGameKeyState(21, 0)
        while getCharHealth(PLAYER_PED) >= 150 do wait(0) end
    end
end