Помогите с Lua скриптом

ScripTER 2.0

Участник
Автор темы
106
4
Помогите решить проблему с Lua
Когда заходит игрок на сервер с ником пример: TohamqDa
то ему сразу дает мут за mq но надо что-бы этот скрипт только работал когда игрок напишет в чат mq
что бы он на ник не срабатывал кто сможет решить проблему?
Буду очень благодарен если он будет работать!
Вот сам код
Код:
function sampev.onServerMessage(color, text)
    if text:find('mq') or text:find('MQ') then
        local id = tonumber(text:match('%((%d+)%)'))
        if id then
            lua_thread.create(function()
                wait(120)
                sampProcessChatInput('/r ' .. id)
            end)
        end
Команда из AdminTool
Вот скрин https://ibb.co/2WVLh8b
 

arc warden

Участник
139
21
мне не надо перед словом надо просто что бы когда он написал mq
тогда используй моё
Lua:
function sampev.onServerMessage(color, text)
    if text:find('%((%d+)): {ffffff}mq') or text:find('%((%d+)): {ffffff}MQ') then
        local id = text:match('%((%d+))')
        wait(120)
        sampSendChat('/or ' .. id)
    end
end
 

ScripTER 2.0

Участник
Автор темы
106
4
скинь фулл код скрипта у меня тут нету ни единого elseif а
local sampev = require 'samp.events'


function sampev.onServerMessage(color, text)
if text:find('%((%d+)): {ffffff}mq') or text:find('%((%d+)): {ffffff}MQ') then
local id = text:match('%((%d+))')
wait(120)
sampSendChat('/or ' .. id)
end
end
 

arc warden

Участник
139
21
local sampev = require 'samp.events'


function sampev.onServerMessage(color, text)
if text:find('%((%d+)): {ffffff}mq') or text:find('%((%d+)): {ffffff}MQ') then
local id = text:match('%((%d+))')
wait(120)
sampSendChat('/or ' .. id)
end
end
Код:
function sampev.onServerMessage(color, text)
    if text:find('%((%d+)): {ffffff}mq')
        local id = text:match('%((%d+))')
        wait(120)
        sampSendChat('/or ' .. id)
    elseif text:find('%((%d+)): {ffffff}MQ') then
        wait(120)
        sampSendChat('/or ' .. id)
    end

Код:
function sampev.onServerMessage(color, text)
    if text:find('%((%d+)): {ffffff}mq')
        local id = text:match('%((%d+))')
        wait(120)
        sampSendChat('/or ' .. id)
    elseif text:find('%((%d+)): {ffffff}MQ') then
        wait(120)
        sampSendChat('/or ' .. id)
    end
через elseif делаем потому что поч не пропускает через or в if'e

и еще один end добавь в конце
 

ScripTER 2.0

Участник
Автор темы
106
4
Код:
function sampev.onServerMessage(color, text)
    if text:find('%((%d+)): {ffffff}mq')
        local id = text:match('%((%d+))')
        wait(120)
        sampSendChat('/or ' .. id)
    elseif text:find('%((%d+)): {ffffff}MQ') then
        wait(120)
        sampSendChat('/or ' .. id)
    end


через elseif делаем потому что поч не пропускает через or в if'e

и еще один end добавь в конце
не че не поменялось!
 

arc warden

Участник
139
21
у меня все запускается без ошибок. Я только пропустил then после условия if'a


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

function sampev.onServerMessage(color, text)
    if text:find('%((%d+)): {ffffff}mq') then
        local id = text:match('%((%d+))')
        wait(120)
        sampSendChat('/or ' .. id)
    elseif text:find('%((%d+)): {ffffff}MQ') then
        wait(120)
        sampSendChat('/or ' .. id)
    end
end
 

ScripTER 2.0

Участник
Автор темы
106
4
Lua:
local sampev = require 'lib.samp.events'

function sampev.onServerMessage(color, text)
    if text:find('%((%d+)%): %{......%}mq') or text:find('%((%d+)%): %{......%}MQ') then
        local id = tonumber(text:match('%((%d+)%)'))
        if id then
            lua_thread.create(function()
                wait(120)
                sampProcessChatInput('/or ' .. id)
            end)
        end
    end
end
проверю

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

function sampev.onServerMessage(color, text)
    if text:find('%((%d+)%): %{......%}mq') or text:find('%((%d+)%): %{......%}MQ') then
        local id = tonumber(text:match('%((%d+)%)'))
        if id then
            lua_thread.create(function()
                wait(120)
                sampProcessChatInput('/or ' .. id)
            end)
        end
    end
end
Работает спасибо
 
Последнее редактирование: