Ищу скрипт на ввод команды после ввода сообщения

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

Cominchick

Участник
Автор темы
5
0
Ищу специальный скрипт, который автоматически будет вводить команду Игроку, который напишет специальное слово
Пример:
Игрок: Лек
Я: /heal [id/ник] [cумма]
 
Решение
Lua:
local sampev = require 'samp.events'

function sampev.onServerMessage(color, text)
    -- Проверка на текст
    if text:find('Лек') then
        -- Поиск айди игрока
        local id = tonumber(text:match('%((%d+)%)'))
        if id then
            lua_thread.create(function() wait(200) -- Задержка
            sampSendChat('/heal ' .. id ..  ' 500') -- Сообщение
            end)
        end
    end
end

UPD:
Lua:
local sampev = require 'samp.events'

local list = {
    '(.+)ек',
    '(.+)ечи',
    '(.+)олова',
    '(.+)аблетку',
    '(.+)хил'
}

function sampev.onServerMessage(color, text)
    for _, pattern in ipairs(list) do
        if text:find(pattern) then
            local id = text:match('%((%d+)%)')
            if id then...

Heav

Активный
186
66
Lua:
local sampev = require 'samp.events'

function sampev.onServerMessage(color, text)
    -- Проверка на текст
    if text:find('Лек') then
        -- Поиск айди игрока
        local id = tonumber(text:match('%((%d+)%)'))
        if id then
            lua_thread.create(function() wait(200) -- Задержка
            sampSendChat('/heal ' .. id ..  ' 500') -- Сообщение
            end)
        end
    end
end

UPD:
Lua:
local sampev = require 'samp.events'

local list = {
    '(.+)ек',
    '(.+)ечи',
    '(.+)олова',
    '(.+)аблетку',
    '(.+)хил'
}

function sampev.onServerMessage(color, text)
    for _, pattern in ipairs(list) do
        if text:find(pattern) then
            local id = text:match('%((%d+)%)')
            if id then
                lua_thread.create(function()
                    wait(200)
                    sampSendChat('/heal ' .. tostring(id))
                end)
            end
        end
    end
end
 

Вложения

  • heal.lua
    419 байт · Просмотры: 4
  • healupd.lua
    526 байт · Просмотры: 5
Последнее редактирование:
  • Нравится
Реакции: Cominchick

976h

Участник
93
34
Lua:
local sampev = require 'samp.events'

function sampev.onServerMessage(color, text)
    -- Проверка на текст
    if text:find('Лек') then
        -- Поиск айди игрока
        local id = tonumber(text:match('%((%d+)%)'))
        if id then
            lua_thread.create(function() wait(200) -- Задержка
            sampSendChat('/heal ' .. id ..  ' 500') -- Сообщение
            end)
        end
    end
end
Код был написан через ChatGPT :D, да еще и не рабочий

Держи если над

Lua:
local sampev = require "lib.samp.events"

function sampev.onServerMessage(clr, text)
    if text:find("(.+)ек") or text:find("(.+)ечи") or text:find("(.+)олова") or text:find("(.+)аблетку") then
        lua_thread.create(function()
            local id = text:match("%d+")
            if id then
                wait(200)
                sampProcessChatInput("/heal " .. tostring(id))
            end
        end)
    end
end
 

Heav

Активный
186
66
Код был написан через ChatGPT :D, да еще и не рабочий

Держи если над

Lua:
local sampev = require "lib.samp.events"

function sampev.onServerMessage(clr, text)
    if text:find("(.+)ек") or text:find("(.+)ечи") or text:find("(.+)олова") or text:find("(.+)аблетку") then
        lua_thread.create(function()
            local id = text:match("%d+")
            if id then
                wait(200)
                sampProcessChatInput("/heal " .. tostring(id))
            end
        end)
    end
end
Ты его хоть проверил чтобы это утверждение сделать?
 

976h

Участник
93
34
Ты его хоть проверил чтобы это утверждение сделать?
1688753877036.png

проверить легко
 
Последнее редактирование:
Статус
В этой теме нельзя размещать новые ответы.