2 аргумента в команде

Статус
В этой теме нельзя размещать новые ответы.

Sanurial

Участник
Автор темы
78
12
Версия MoonLoader
.026-beta
Lua:
sampRegisterChatCommand('ans', function(id, text)
        if id and text then
            sampAddChatMessage(tag .. tostring(id) .. ' | ' .. text, -1)
            sampSendChat('/ans ' .. tostring(id) .. ' ' .. text)
            ini.admin.dcountAns = ini.admin.dcountAns + 1
            ini.admin.ecountAns = ini.admin.ecountAns + 1
            inicfg.save(ini, directIni)
        else
            sampAddChatMessage(tag .. '/ans [id] [ответ]', -1)
            sampAddChatMessage(tag .. 'ID: ' .. tostring(id) .. ', TEXT: ' .. tostring(text), -1)
        end
    resetDcountAnsMsk()
    end)

Вот это выдаёт следующее:

Lua:
sampRegisterChatCommand('ans', function(params)
        local id, text = tonumber(params[1]), tostring(params[2])
        if id and text then
            sampAddChatMessage(tostring(id) .. ' | ' .. text, -1)
            sampSendChat('/ans ' .. tostring(id) .. ' ' .. text)
            ini.admin.dcountAns = ini.admin.dcountAns + 1
            ini.admin.ecountAns = ini.admin.ecountAns + 1
            inicfg.save(ini, directIni)
        else
            sampAddChatMessage('/ans [id] [ответ]', -1)
            sampAddChatMessage(tag .. 'ID: ' .. tostring(id) .. ', TEXT: ' .. tostring(text), -1)
        end
        resetDcountAnsMsk()
    end)
 
Решение
Lua:
sampRegisterChatCommand('ans', function(params)
        local id, text = params:match("(%d+) (.+)")
        id = tonumber(id)
        if id and text then
            sampAddChatMessage(tostring(id) .. ' | ' .. text, -1)
            sampSendChat('/ans ' .. tostring(id) .. ' ' .. text)
            ini.admin.dcountAns = ini.admin.dcountAns + 1
            ini.admin.ecountAns = ini.admin.ecountAns + 1
            inicfg.save(ini, directIni)
        else
            sampAddChatMessage('/ans [id] [ответ]', -1)
            sampAddChatMessage(tag .. 'ID: ' .. tostring(id) .. ', TEXT: ' .. tostring(text), -1)
        end
        resetDcountAnsMsk()
    end)
Попробуй так

Сам уже нашел как сделать, спасибо)...

YarikVL

Известный
Проверенный
4,798
1,814
Lua:
sampRegisterChatCommand('ans', function(id, text)
        if id and text then
            sampAddChatMessage(tag .. tostring(id) .. ' | ' .. text, -1)
            sampSendChat('/ans ' .. tostring(id) .. ' ' .. text)
            ini.admin.dcountAns = ini.admin.dcountAns + 1
            ini.admin.ecountAns = ini.admin.ecountAns + 1
            inicfg.save(ini, directIni)
        else
            sampAddChatMessage(tag .. '/ans [id] [ответ]', -1)
            sampAddChatMessage(tag .. 'ID: ' .. tostring(id) .. ', TEXT: ' .. tostring(text), -1)
        end
    resetDcountAnsMsk()
    end)

Вот это выдаёт следующее:

Lua:
sampRegisterChatCommand('ans', function(params)
        local id, text = tonumber(params[1]), tostring(params[2])
        if id and text then
            sampAddChatMessage(tostring(id) .. ' | ' .. text, -1)
            sampSendChat('/ans ' .. tostring(id) .. ' ' .. text)
            ini.admin.dcountAns = ini.admin.dcountAns + 1
            ini.admin.ecountAns = ini.admin.ecountAns + 1
            inicfg.save(ini, directIni)
        else
            sampAddChatMessage('/ans [id] [ответ]', -1)
            sampAddChatMessage(tag .. 'ID: ' .. tostring(id) .. ', TEXT: ' .. tostring(text), -1)
        end
        resetDcountAnsMsk()
    end)
Lua:
sampRegisterChatCommand('ans', function(params)
        local id, text = params:match("(%d+) (.+)")
        id = tonumber(id)
        if id and text then
            sampAddChatMessage(tostring(id) .. ' | ' .. text, -1)
            sampSendChat('/ans ' .. tostring(id) .. ' ' .. text)
            ini.admin.dcountAns = ini.admin.dcountAns + 1
            ini.admin.ecountAns = ini.admin.ecountAns + 1
            inicfg.save(ini, directIni)
        else
            sampAddChatMessage('/ans [id] [ответ]', -1)
            sampAddChatMessage(tag .. 'ID: ' .. tostring(id) .. ', TEXT: ' .. tostring(text), -1)
        end
        resetDcountAnsMsk()
    end)
Попробуй так
 
  • Нравится
Реакции: MLycoris

Sanurial

Участник
Автор темы
78
12
Lua:
sampRegisterChatCommand('ans', function(params)
        local id, text = params:match("(%d+) (.+)")
        id = tonumber(id)
        if id and text then
            sampAddChatMessage(tostring(id) .. ' | ' .. text, -1)
            sampSendChat('/ans ' .. tostring(id) .. ' ' .. text)
            ini.admin.dcountAns = ini.admin.dcountAns + 1
            ini.admin.ecountAns = ini.admin.ecountAns + 1
            inicfg.save(ini, directIni)
        else
            sampAddChatMessage('/ans [id] [ответ]', -1)
            sampAddChatMessage(tag .. 'ID: ' .. tostring(id) .. ', TEXT: ' .. tostring(text), -1)
        end
        resetDcountAnsMsk()
    end)
Попробуй так

Сам уже нашел как сделать, спасибо)
Lua:
sampRegisterChatCommand('ans', function(answer)
        if #answer == 0 then
            sampAddChatMessage(tag .. '/ans [id] [ответ]', -1)

        else
            local id, text = answer:match('(.+) (.*)')
            sampAddChatMessage(tag .. tostring(id) .. ' | ' .. text, -1)
            sampSendChat('/ans ' .. id .. ' ' .. text)
            ini.admin.dcountAns = ini.admin.dcountAns + 1
            ini.admin.ecountAns = ini.admin.ecountAns + 1
            inicfg.save(ini, directIni)
        end
        resetDcountAnsMsk()
    end)
 
Статус
В этой теме нельзя размещать новые ответы.