Помогите добавить задержку

Insanity

Известный
Автор темы
248
20
Существует скрипт от Cosmo "Command Arguments"
Суть в том, что можно в одну команду запихнуть несколько ID и скрипт будет их по очереди садить, что бы не писать одну смд с несколькими ид. Но в этом скрипте нет задержки и для других проектов где есть "не флуди" он не подходит. Один товарищ сказал, что задержку можно поставить (35-36 строке), но я не шарю, помогите плз.
Код:
script_name('Arguments')
script_author('Cosmo')

require "moonloader"
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(80) end
    local font = renderCreateFont('Arial', 8, 5) -- Что бы изменить размер шрифта, поменяйте цифру 8 на другую
    while true do
        if sampIsChatInputActive() then
            local s = sampGetChatInputText():match('^/.+%($')
            if s then sampSetChatInputText(s..")"); sampSetChatInputCursor(s:len()) end
        end

        local args = sampGetChatInputText():match('^/.+%([%d%s]+%)')
        if args and sampIsChatInputActive() then
            local strEl = getStructElement(sampGetInputInfoPtr(), 0x8, 4)
            local X = getStructElement(strEl, 0x8, 4) + 5
            local Y = getStructElement(strEl, 0xC, 4) + 50
            for a in args:gmatch('%d+') do
                local rstr = sampGetChatInputText():gsub('%([%d%s]+%)', '{FFD000}'..a..'{008000}')
                renderFontDrawText(font, rstr, X, Y, 0xFF008000)
                renderFontDrawText(font, (sampIsPlayerConnected(a) and ' -> '..sampGetPlayerNickname(a) or '{FF5050} -> Не существует!'), X + renderGetFontDrawTextLength(font, rstr), Y, 0x80AFAFAF)
                Y = Y + 13
            end
        end
    wait(0)
    end
end

local se = require 'lib.samp.events'
function se.onSendCommand(cmd)
    local args = cmd:match('^/.+%([%d%s]+%)')
    if args then
        for a in args:gmatch('%d+') do
            sampSendChat( cmd:gsub('%([%d%s]+%)', a, 1) )   
        end
        return false
    end
end

function sampSetChatInputCursor(start, finish)
    local finish = finish or start
    local start, finish = tonumber(start), tonumber(finish)
    local mem = require 'memory'
    local chatInfoPtr = sampGetInputInfoPtr()
    local chatBoxInfo = getStructElement(chatInfoPtr, 0x8, 4)
    mem.setint8(chatBoxInfo + 0x11E, start)
    mem.setint8(chatBoxInfo + 0x119, finish)
    return true
end
 
Решение
Lua:
script_name('Arguments')
script_author('Cosmo')
require "moonloader"
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(80) end
    local font = renderCreateFont('Arial', 8, 5) -- Что бы изменить размер шрифта, поменяйте цифру 8 на другую
    while true do
        if sampIsChatInputActive() then
            local s = sampGetChatInputText():match('^/.+%($')
            if s then sampSetChatInputText(s..")"); sampSetChatInputCursor(s:len()) end
        end
        local args = sampGetChatInputText():match('^/.+%([%d%s]+%)')
        if args and sampIsChatInputActive() then
            local strEl = getStructElement(sampGetInputInfoPtr(), 0x8, 4)
            local...

Asoka

Известный
22
2
Где именно? После чего? Я вообще ничего не понимаю, помоги пожалуйста
Lua:
script_name('Arguments')
script_author('Cosmo')

require "moonloader"
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(80) end
    local font = renderCreateFont('Arial', 8, 5) -- Что бы изменить размер шрифта, поменяйте цифру 8 на другую
    while true do
        if sampIsChatInputActive() then
            local s = sampGetChatInputText():match('^/.+%($')
            if s then sampSetChatInputText(s..")"); sampSetChatInputCursor(s:len()) end
        end

        local args = sampGetChatInputText():match('^/.+%([%d%s]+%)')
        if args and sampIsChatInputActive() then
            local strEl = getStructElement(sampGetInputInfoPtr(), 0x8, 4)
            local X = getStructElement(strEl, 0x8, 4) + 5
            local Y = getStructElement(strEl, 0xC, 4) + 50
            for a in args:gmatch('%d+') do
                local rstr = sampGetChatInputText():gsub('%([%d%s]+%)', '{FFD000}'..a..'{008000}')
                renderFontDrawText(font, rstr, X, Y, 0xFF008000)
                renderFontDrawText(font, (sampIsPlayerConnected(a) and ' -> '..sampGetPlayerNickname(a) or '{FF5050} -> Не существует!'), X + renderGetFontDrawTextLength(font, rstr), Y, 0x80AFAFAF)
                Y = Y + 13
            end
        end
    wait(0)
    end
end

local se = require 'lib.samp.events'
function se.onSendCommand(cmd)
    local args = cmd:match('^/.+%([%d%s]+%)')
    if args then
        for a in args:gmatch('%d+') do
            sampSendChat( cmd:gsub('%([%d%s]+%)', a, 1) )
            wait(1005)
        end
        return false
    end
end

function sampSetChatInputCursor(start, finish)
    local finish = finish or start
    local start, finish = tonumber(start), tonumber(finish)
    local mem = require 'memory'
    local chatInfoPtr = sampGetInputInfoPtr()
    local chatBoxInfo = getStructElement(chatInfoPtr, 0x8, 4)
    mem.setint8(chatBoxInfo + 0x11E, start)
    mem.setint8(chatBoxInfo + 0x119, finish)
    return true
end
 

Insanity

Известный
Автор темы
248
20
Lua:
script_name('Arguments')
script_author('Cosmo')

require "moonloader"
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(80) end
    local font = renderCreateFont('Arial', 8, 5) -- Что бы изменить размер шрифта, поменяйте цифру 8 на другую
    while true do
        if sampIsChatInputActive() then
            local s = sampGetChatInputText():match('^/.+%($')
            if s then sampSetChatInputText(s..")"); sampSetChatInputCursor(s:len()) end
        end

        local args = sampGetChatInputText():match('^/.+%([%d%s]+%)')
        if args and sampIsChatInputActive() then
            local strEl = getStructElement(sampGetInputInfoPtr(), 0x8, 4)
            local X = getStructElement(strEl, 0x8, 4) + 5
            local Y = getStructElement(strEl, 0xC, 4) + 50
            for a in args:gmatch('%d+') do
                local rstr = sampGetChatInputText():gsub('%([%d%s]+%)', '{FFD000}'..a..'{008000}')
                renderFontDrawText(font, rstr, X, Y, 0xFF008000)
                renderFontDrawText(font, (sampIsPlayerConnected(a) and ' -> '..sampGetPlayerNickname(a) or '{FF5050} -> Не существует!'), X + renderGetFontDrawTextLength(font, rstr), Y, 0x80AFAFAF)
                Y = Y + 13
            end
        end
    wait(0)
    end
end

local se = require 'lib.samp.events'
function se.onSendCommand(cmd)
    local args = cmd:match('^/.+%([%d%s]+%)')
    if args then
        for a in args:gmatch('%d+') do
            sampSendChat( cmd:gsub('%([%d%s]+%)', a, 1) )
            wait(1005)
        end
        return false
    end
end

function sampSetChatInputCursor(start, finish)
    local finish = finish or start
    local start, finish = tonumber(start), tonumber(finish)
    local mem = require 'memory'
    local chatInfoPtr = sampGetInputInfoPtr()
    local chatBoxInfo = getStructElement(chatInfoPtr, 0x8, 4)
    mem.setint8(chatBoxInfo + 0x11E, start)
    mem.setint8(chatBoxInfo + 0x119, finish)
    return true
end
Я делал тоже самое, не работает. Я читал что только в mine могут быть wait'ы
 

chapo

🫡 В армии с 17.10.2023. В ЛС НЕ ОТВЕЧАЮ
Друг
8,771
11,214
на 6 строке в переменной delay введи задержку
Lua:
script_name('Arguments')
script_author('Cosmo')

require "moonloader"

local delay = 1500 --задержка (1000 = 1 сек.)

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(80) end
    local font = renderCreateFont('Arial', 8, 5) -- Что бы изменить размер шрифта, поменяйте цифру 8 на другую
    while true do
        if sampIsChatInputActive() then
            local s = sampGetChatInputText():match('^/.+%($')
            if s then sampSetChatInputText(s..")"); sampSetChatInputCursor(s:len()) end
        end

        local args = sampGetChatInputText():match('^/.+%([%d%s]+%)')
        if args and sampIsChatInputActive() then
            local strEl = getStructElement(sampGetInputInfoPtr(), 0x8, 4)
            local X = getStructElement(strEl, 0x8, 4) + 5
            local Y = getStructElement(strEl, 0xC, 4) + 50
            for a in args:gmatch('%d+') do
                local rstr = sampGetChatInputText():gsub('%([%d%s]+%)', '{FFD000}'..a..'{008000}')
                renderFontDrawText(font, rstr, X, Y, 0xFF008000)
                renderFontDrawText(font, (sampIsPlayerConnected(a) and ' -> '..sampGetPlayerNickname(a) or '{FF5050} -> Не существует!'), X + renderGetFontDrawTextLength(font, rstr), Y, 0x80AFAFAF)
                Y = Y + 13
            end
        end
    wait(0)
    end
end

local se = require 'lib.samp.events'
function se.onSendCommand(cmd)
    local args = cmd:match('^/.+%([%d%s]+%)')
    if args then
        for a in args:gmatch('%d+') do
            lua_thread.create(function()
                sampSendChat( cmd:gsub('%([%d%s]+%)', a, 1) )
                wait(delay)
            end)
        end
        return false
    end
end

function sampSetChatInputCursor(start, finish)
    local finish = finish or start
    local start, finish = tonumber(start), tonumber(finish)
    local mem = require 'memory'
    local chatInfoPtr = sampGetInputInfoPtr()
    local chatBoxInfo = getStructElement(chatInfoPtr, 0x8, 4)
    mem.setint8(chatBoxInfo + 0x11E, start)
    mem.setint8(chatBoxInfo + 0x119, finish)
    return true
end
 

Insanity

Известный
Автор темы
248
20
на 6 строке в переменной delay введи задержку
Lua:
script_name('Arguments')
script_author('Cosmo')

require "moonloader"

local delay = 1500 --задержка (1000 = 1 сек.)

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(80) end
    local font = renderCreateFont('Arial', 8, 5) -- Что бы изменить размер шрифта, поменяйте цифру 8 на другую
    while true do
        if sampIsChatInputActive() then
            local s = sampGetChatInputText():match('^/.+%($')
            if s then sampSetChatInputText(s..")"); sampSetChatInputCursor(s:len()) end
        end

        local args = sampGetChatInputText():match('^/.+%([%d%s]+%)')
        if args and sampIsChatInputActive() then
            local strEl = getStructElement(sampGetInputInfoPtr(), 0x8, 4)
            local X = getStructElement(strEl, 0x8, 4) + 5
            local Y = getStructElement(strEl, 0xC, 4) + 50
            for a in args:gmatch('%d+') do
                local rstr = sampGetChatInputText():gsub('%([%d%s]+%)', '{FFD000}'..a..'{008000}')
                renderFontDrawText(font, rstr, X, Y, 0xFF008000)
                renderFontDrawText(font, (sampIsPlayerConnected(a) and ' -> '..sampGetPlayerNickname(a) or '{FF5050} -> Не существует!'), X + renderGetFontDrawTextLength(font, rstr), Y, 0x80AFAFAF)
                Y = Y + 13
            end
        end
    wait(0)
    end
end

local se = require 'lib.samp.events'
function se.onSendCommand(cmd)
    local args = cmd:match('^/.+%([%d%s]+%)')
    if args then
        for a in args:gmatch('%d+') do
            lua_thread.create(function()
                sampSendChat( cmd:gsub('%([%d%s]+%)', a, 1) )
                wait(delay)
            end)
        end
        return false
    end
end

function sampSetChatInputCursor(start, finish)
    local finish = finish or start
    local start, finish = tonumber(start), tonumber(finish)
    local mem = require 'memory'
    local chatInfoPtr = sampGetInputInfoPtr()
    local chatBoxInfo = getStructElement(chatInfoPtr, 0x8, 4)
    mem.setint8(chatBoxInfo + 0x11E, start)
    mem.setint8(chatBoxInfo + 0x119, finish)
    return true
end
Не работает. Вернее работает, но так же без задержки - "не флуди"
 

chapo

🫡 В армии с 17.10.2023. В ЛС НЕ ОТВЕЧАЮ
Друг
8,771
11,214
Не работает. Вернее работает, но так же без задержки - "не флуди"
попробуй увеличить задержку

или попробуй так:


Lua:
script_name('Arguments')
script_author('Cosmo')

require "moonloader"

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(80) end
    local font = renderCreateFont('Arial', 8, 5) -- Что бы изменить размер шрифта, поменяйте цифру 8 на другую
    while true do
        if sampIsChatInputActive() then
            local s = sampGetChatInputText():match('^/.+%($')
            if s then sampSetChatInputText(s..")"); sampSetChatInputCursor(s:len()) end
        end

        local args = sampGetChatInputText():match('^/.+%([%d%s]+%)')
        if args and sampIsChatInputActive() then
            local strEl = getStructElement(sampGetInputInfoPtr(), 0x8, 4)
            local X = getStructElement(strEl, 0x8, 4) + 5
            local Y = getStructElement(strEl, 0xC, 4) + 50
            for a in args:gmatch('%d+') do
                local rstr = sampGetChatInputText():gsub('%([%d%s]+%)', '{FFD000}'..a..'{008000}')
                renderFontDrawText(font, rstr, X, Y, 0xFF008000)
                renderFontDrawText(font, (sampIsPlayerConnected(a) and ' -> '..sampGetPlayerNickname(a) or '{FF5050} -> Не существует!'), X + renderGetFontDrawTextLength(font, rstr), Y, 0x80AFAFAF)
                Y = Y + 13
            end
        end
    wait(0)
    end
end

local se = require 'lib.samp.events'
function se.onSendCommand(cmd)
    local args = cmd:match('^/.+%([%d%s]+%)')
    if args then
        for a in args:gmatch('%d+') do
            lua_thread.create(function()
                wait(1550)
                sampSendChat( cmd:gsub('%([%d%s]+%)', a, 1) )
            end)
        end
        return false
    end
end

function sampSetChatInputCursor(start, finish)
    local finish = finish or start
    local start, finish = tonumber(start), tonumber(finish)
    local mem = require 'memory'
    local chatInfoPtr = sampGetInputInfoPtr()
    local chatBoxInfo = getStructElement(chatInfoPtr, 0x8, 4)
    mem.setint8(chatBoxInfo + 0x11E, start)
    mem.setint8(chatBoxInfo + 0x119, finish)
    return true
end
 

Insanity

Известный
Автор темы
248
20
попробуй увеличить задержку

или попробуй так:


Lua:
script_name('Arguments')
script_author('Cosmo')

require "moonloader"

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(80) end
    local font = renderCreateFont('Arial', 8, 5) -- Что бы изменить размер шрифта, поменяйте цифру 8 на другую
    while true do
        if sampIsChatInputActive() then
            local s = sampGetChatInputText():match('^/.+%($')
            if s then sampSetChatInputText(s..")"); sampSetChatInputCursor(s:len()) end
        end

        local args = sampGetChatInputText():match('^/.+%([%d%s]+%)')
        if args and sampIsChatInputActive() then
            local strEl = getStructElement(sampGetInputInfoPtr(), 0x8, 4)
            local X = getStructElement(strEl, 0x8, 4) + 5
            local Y = getStructElement(strEl, 0xC, 4) + 50
            for a in args:gmatch('%d+') do
                local rstr = sampGetChatInputText():gsub('%([%d%s]+%)', '{FFD000}'..a..'{008000}')
                renderFontDrawText(font, rstr, X, Y, 0xFF008000)
                renderFontDrawText(font, (sampIsPlayerConnected(a) and ' -> '..sampGetPlayerNickname(a) or '{FF5050} -> Не существует!'), X + renderGetFontDrawTextLength(font, rstr), Y, 0x80AFAFAF)
                Y = Y + 13
            end
        end
    wait(0)
    end
end

local se = require 'lib.samp.events'
function se.onSendCommand(cmd)
    local args = cmd:match('^/.+%([%d%s]+%)')
    if args then
        for a in args:gmatch('%d+') do
            lua_thread.create(function()
                wait(1550)
                sampSendChat( cmd:gsub('%([%d%s]+%)', a, 1) )
            end)
        end
        return false
    end
end

function sampSetChatInputCursor(start, finish)
    local finish = finish or start
    local start, finish = tonumber(start), tonumber(finish)
    local mem = require 'memory'
    local chatInfoPtr = sampGetInputInfoPtr()
    local chatBoxInfo = getStructElement(chatInfoPtr, 0x8, 4)
    mem.setint8(chatBoxInfo + 0x11E, start)
    mem.setint8(chatBoxInfo + 0x119, finish)
    return true
end
Тоже нет, вводишь команду и он через секунду срабатывает.
И задержку в том код в 10 раз увеличивал. А сохранение как-то влияет? Или не важно там в какой кодировке
 

chapo

🫡 В армии с 17.10.2023. В ЛС НЕ ОТВЕЧАЮ
Друг
8,771
11,214
Тоже нет, вводишь команду и он через секунду срабатывает.
И задержку в том код в 10 раз увеличивал. А сохранение как-то влияет? Или не важно там в какой кодировке
кодировка вроде никак не влияет
 

|| NN - NoName ||

Известный
1,049
628
Lua:
script_name('Arguments')
script_author('Cosmo')
require "moonloader"
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(80) end
    local font = renderCreateFont('Arial', 8, 5) -- Что бы изменить размер шрифта, поменяйте цифру 8 на другую
    while true do
        if sampIsChatInputActive() then
            local s = sampGetChatInputText():match('^/.+%($')
            if s then sampSetChatInputText(s..")"); sampSetChatInputCursor(s:len()) end
        end
        local args = sampGetChatInputText():match('^/.+%([%d%s]+%)')
        if args and sampIsChatInputActive() then
            local strEl = getStructElement(sampGetInputInfoPtr(), 0x8, 4)
            local X = getStructElement(strEl, 0x8, 4) + 5
            local Y = getStructElement(strEl, 0xC, 4) + 50
            for a in args:gmatch('%d+') do
                local rstr = sampGetChatInputText():gsub('%([%d%s]+%)', '{FFD000}'..a..'{008000}')
                renderFontDrawText(font, rstr, X, Y, 0xFF008000)
                renderFontDrawText(font, (sampIsPlayerConnected(a) and ' -> '..sampGetPlayerNickname(a) or '{FF5050} -> Не существует!'), X + renderGetFontDrawTextLength(font, rstr), Y, 0x80AFAFAF)
                Y = Y + 13
            end
        end
    wait(0)
    end
end
local se = require 'lib.samp.events'
function se.onSendCommand(cmd)
    local args = cmd:match('^/.+%([%d%s]+%)')
    if args then
      lua_thread.create(function()
        for a in args:gmatch('%d+') do
            sampSendChat( cmd:gsub('%([%d%s]+%)', a, 1) )
            wait(500) -- задержка в МС
        end
      end)
        return false
    end
end
function sampSetChatInputCursor(start, finish)
    local finish = finish or start
    local start, finish = tonumber(start), tonumber(finish)
    local mem = require 'memory'
    local chatInfoPtr = sampGetInputInfoPtr()
    local chatBoxInfo = getStructElement(chatInfoPtr, 0x8, 4)
    mem.setint8(chatBoxInfo + 0x11E, start)
    mem.setint8(chatBoxInfo + 0x119, finish)
    return true
end
 
  • Нравится
Реакции: фидарза и Insanity

Insanity

Известный
Автор темы
248
20
Lua:
script_name('Arguments')
script_author('Cosmo')
require "moonloader"
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(80) end
    local font = renderCreateFont('Arial', 8, 5) -- Что бы изменить размер шрифта, поменяйте цифру 8 на другую
    while true do
        if sampIsChatInputActive() then
            local s = sampGetChatInputText():match('^/.+%($')
            if s then sampSetChatInputText(s..")"); sampSetChatInputCursor(s:len()) end
        end
        local args = sampGetChatInputText():match('^/.+%([%d%s]+%)')
        if args and sampIsChatInputActive() then
            local strEl = getStructElement(sampGetInputInfoPtr(), 0x8, 4)
            local X = getStructElement(strEl, 0x8, 4) + 5
            local Y = getStructElement(strEl, 0xC, 4) + 50
            for a in args:gmatch('%d+') do
                local rstr = sampGetChatInputText():gsub('%([%d%s]+%)', '{FFD000}'..a..'{008000}')
                renderFontDrawText(font, rstr, X, Y, 0xFF008000)
                renderFontDrawText(font, (sampIsPlayerConnected(a) and ' -> '..sampGetPlayerNickname(a) or '{FF5050} -> Не существует!'), X + renderGetFontDrawTextLength(font, rstr), Y, 0x80AFAFAF)
                Y = Y + 13
            end
        end
    wait(0)
    end
end
local se = require 'lib.samp.events'
function se.onSendCommand(cmd)
    local args = cmd:match('^/.+%([%d%s]+%)')
    if args then
      lua_thread.create(function()
        for a in args:gmatch('%d+') do
            sampSendChat( cmd:gsub('%([%d%s]+%)', a, 1) )
            wait(500) -- задержка в МС
        end
      end)
        return false
    end
end
function sampSetChatInputCursor(start, finish)
    local finish = finish or start
    local start, finish = tonumber(start), tonumber(finish)
    local mem = require 'memory'
    local chatInfoPtr = sampGetInputInfoPtr()
    local chatBoxInfo = getStructElement(chatInfoPtr, 0x8, 4)
    mem.setint8(chatBoxInfo + 0x11E, start)
    mem.setint8(chatBoxInfo + 0x119, finish)
    return true
end
Офигеть, я не знаю что ты сделал, но это помогло. Спасибо тебе огромное!
Спасибо!