Помогите написать код

Diqeey

Активный
Автор темы
444
61
Версия MoonLoader
.026-beta
Нужен биндер чтобы при вводе команды определённой( /mp {id} ) он начинал флуд с задержкой 0.8 сек командой /pay {id} 1, а когда доллар перекинется остановил флуд.
Вот я написал половина кода допишите пж я не умею вообще а я вам спасибо скажу
1626678156608.png



Lua:
require "lib.moonloader"
function main()
  if not isSampfuncsLoaded() or not isSampLoaded() then return end
  while not isSampAvailable() do wait(100) end
  while true do
  wait(0)
    if sampRegisterChatCommand('/mp') then
      sampSendChat("/pay 1")
    end
  end
  end
 
Решение
Lua:
local globus = false
local samp = require 'samp.events'
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand('/mp', function(id)
        globus = true
        if thread then thread:terminate() end
        thread = lua_thread.create(function()
            while globus do
                sampSendChat(string.format('/pay %s 1', id))
                wait(700)
            end
        end)
    end)
    wait(-1)
end

function samp.onServerMessage(color, text)
    if text:find('Вы передали') then
        globus = false
    end
end

Diqeey

Активный
Автор темы
444
61
Нихуя не понятно. Научись грамотно выкладывать мысли, либо писать скрипты сам.
Посмотреть вложение 105908
Нужна команда с одной лишь переменной.
Например: я пишу /mp {id} и начинается флуд командой /pay {id} 1 с задержкой 0.7 сек (700 мс), будет передавать пока не передаст, дальше - сам выключится, пока я снова не впишу /mp {id}
понятней тебе бро
1626678935988.png
 

Fott

Простреленный
3,433
2,278
Lua:
local globus = false
local samp = require 'samp.events'
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand('/mp', function(id)
        globus = true
        if thread then thread:terminate() end
        thread = lua_thread.create(function()
            while globus do
                sampSendChat(string.format('/pay %s 1', id))
                wait(700)
            end
        end)
    end)
    wait(-1)
end

function samp.onServerMessage(color, text)
    if text:find('Вы передали') then
        globus = false
    end
end
 

meowprd

Тот самый Котовский
Проверенный
1,280
712
Lua:
local globus = false
local samp = require 'samp.events'
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand('/mp', function(id)
        globus = true
        if thread then thread:terminate() end
        thread = lua_thread.create(function()
            while globus do
                sampSendChat(string.format('/pay %s 1', id))
                wait(700)
            end
        end)
    end)
    wait(-1)
end

function samp.onServerMessage(color, text)
    if text:find('Вы передали') then
        globus = false
    end
end
или, например, вот так:
(без потоков дополнительных типа)
Lua:
local samp = require 'samp.events'
local fId = nil

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

    sampRegisterChatCommand("/mp", function(id)
        if tonumber(id) then fId = tonumber(id)
        else sampAddChatMessage('/mp [id]', -1)
        end
    end)

    while true do
        if id then
            sampSendChat(string.format("/pay %d 1", fId))
            wait(700)
        else
            wait(0)
        end
    end
end

function samp.onServerMessage(color, text)
    if text:find('Вы передали') then
        fId = nil
    end
end