авто слежка

Mr.Mastire222

Известный
Автор темы
528
259
как сделать так, чтобы например при вводе команды /pfind id ставился каждые 2 секунды на него маркер, но игрок должен быть в розыске
 
Решение
Lua:
local active = true
local id = nil

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('pfind', function(arg) 
        if active then --знаю что можно active = not active, но так придется прописывать арг даже для отключения
           active = false
           sampAddChatMessage('pfind off', -1)
        else
            if #arg ~= 0 then
                id = tonumber(arg)
                active = true
                sampAddChatMessage('pfind on', -1)
            end
        end
       
    end)
    while true do
        wait(1400)
        if active then
            sampSendChat('/find '..id)
        end
    end
end

chapo

tg/inst: @moujeek
Всефорумный модератор
9,096
12,126
Lua:
local active = true
local id = nil

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('pfind', function(arg) 
        if active then --знаю что можно active = not active, но так придется прописывать арг даже для отключения
           active = false
           sampAddChatMessage('pfind off', -1)
        else
            if #arg ~= 0 then
                id = tonumber(arg)
                active = true
                sampAddChatMessage('pfind on', -1)
            end
        end
       
    end)
    while true do
        wait(1400)
        if active then
            sampSendChat('/find '..id)
        end
    end
end
 
  • Нравится
Реакции: ghostex и Mr.Mastire222

Mr.Mastire222

Известный
Автор темы
528
259
Lua:
local active = true
local id = nil

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('pfind', function(arg)
        if active then --знаю что можно active = not active, но так придется прописывать арг даже для отключения
           active = false
           sampAddChatMessage('pfind off', -1)
        else
            if #arg ~= 0 then
                id = tonumber(arg)
                active = true
                sampAddChatMessage('pfind on', -1)
            end
        end
     
    end)
    while true do
        wait(1400)
        if active then
            sampSendChat('/find '..id)
        end
    end
end
Ошибка какая то attempt to concatenate upvalue 'id' (a nil value)
 

Mr.Mastire222

Известный
Автор темы
528
259
попробуй заменить nil на -1 на 2 строке
рабоатет, но когда перезапустил сразу начало флудить /find , можно изменить чтобы сразу не начинало? а только с включения
 

chapo

tg/inst: @moujeek
Всефорумный модератор
9,096
12,126
  • Нравится
Реакции: Mr.Mastire222

Mr.Mastire222

Известный
Автор темы
528
259
на 1 строке измени true на false
когда пропысывается этот /find то не работаю меню всякие, Но спасибо большое, мне помогло. А можно как то сделать чтобы задержку не ставить в while true do , у меня там другие функции и они пишуться с задержкой