Вопрос

G W

Участник
Автор темы
141
5
Версия MoonLoader
.026-beta
Как сделать автоответчик для репорта. Например, приходит репорт от игрока: Жалоба от Test_Test[1]: Где купить картошку ? И чтобы скрипт автоматический отвечал на вопрос.
 
Последнее редактирование:
Решение
Через хук чата.
Lua:
function hook.onServerMessage(color, text)
    
end

Делаешь:
Lua:
if text:find("Жалоба от") then
    -- Your code
end

Под Your code подразумеваю:
string.match, sampSendChat и тому подобное.
Дерзай, получаеца?

meowprd

Тот самый Котовский
Проверенный
1,280
712
Через хук чата.
Lua:
function hook.onServerMessage(color, text)
    
end

Делаешь:
Lua:
if text:find("Жалоба от") then
    -- Your code
end

Под Your code подразумеваю:
string.match, sampSendChat и тому подобное.
Дерзай, получаеца?
 
  • Нравится
Реакции: G W

G W

Участник
Автор темы
141
5
Не отправляет ответное сообщение. В чем проблема ?
Код:
require "moonloader"
local samp = require "samp.events"
local keys = require 'vkeys'
require 'lib.moonloader'
function main()
    if not isSampLoaded then return end
    sampAddChatMessage('Загружен.', -1)
    while true do
        wait(0)
    end
end

function samp.onServerMessage(color, text)
    if text:find('Жалоба от игрока %a+)_(%a+)%[(%d+)%]: Тест') then
       sampSendChat('/ap '..id..' Тестовый текст.')
    end
end
 

meowprd

Тот самый Котовский
Проверенный
1,280
712
Не отправляет ответное сообщение. В чем проблема ?
Код:
require "moonloader"
local samp = require "samp.events"
local keys = require 'vkeys'
require 'lib.moonloader'
function main()
    if not isSampLoaded then return end
    sampAddChatMessage('Загружен.', -1)
    while true do
        wait(0)
    end
end

function samp.onServerMessage(color, text)
    if text:find('Жалоба от игрока %a+)_(%a+)%[(%d+)%]: Тест') then
       sampSendChat('/ap '..id..' Тестовый текст.')
    end
end
Text:find находит текст в строке
Для изъятия инфы юзай text:match
 

Izvinisb

Известный
Проверенный
964
598
Не отправляет ответное сообщение. В чем проблема ?
Код:
require "moonloader"
local samp = require "samp.events"
local keys = require 'vkeys'
require 'lib.moonloader'
function main()
    if not isSampLoaded then return end
    sampAddChatMessage('Загружен.', -1)
    while true do
        wait(0)
    end
end

function samp.onServerMessage(color, text)
    if text:find('Жалоба от игрока %a+)_(%a+)%[(%d+)%]: Тест') then
       sampSendChat('/ap '..id..' Тестовый текст.')
    end
end
isSampLoaded() - это функция.
 

G W

Участник
Автор темы
141
5
Отказывается работать. Я не знаю что делать с ней. Можете показать как примерно она должна работать ?
Lua:
require "moonloader"
local samp = require "samp.events"
local keys = require 'vkeys'
require 'lib.moonloader'
function main()
    if not isSampLoaded() then return end
    sampAddChatMessage('Загружен.', -1)
    while true do
        wait(0)
    end
end

function samp.onServerMessage(color, text)
    if text:match('Жалоба от игрока (%a+)_(%a+)%[(%d+)%]: Тест') then
        local id = text:match('Жалоба от игрока (%a+)_(%a+)%[(%d+)%]: Тест')
        sampSendChat('/ap '..id..' ЗББББББББББ!! РАБОТАЙ! АХАЛАЙ МАХАЛАЙ!')
    end
end
 

Izvinisb

Известный
Проверенный
964
598
Отказывается работать. Я не знаю что делать с ней. Можете показать как примерно она должна работать ?
Lua:
require "moonloader"
local samp = require "samp.events"
local keys = require 'vkeys'
require 'lib.moonloader'
function main()
    if not isSampLoaded() then return end
    sampAddChatMessage('Загружен.', -1)
    while true do
        wait(0)
    end
end

function samp.onServerMessage(color, text)
    if text:match('Жалоба от игрока (%a+)_(%a+)%[(%d+)%]: Тест') then
        local id = text:match('Жалоба от игрока (%a+)_(%a+)%[(%d+)%]: Тест')
        sampSendChat('/ap '..id..' ЗББББББББББ!! РАБОТАЙ! АХАЛАЙ МАХАЛАЙ!')
    end
end
Проверку на загрузку поменяй: repeat wait(0) until isSampAvailble().
if text:find(' Жалоба от игрока (%w+.%w+) %[(%d+)%]:(.*)') then
local nick, id, other = text:match(' Жалоба от игрока (%w+.%w+) %[(%d+)%]:(.*)')
и дальше sampSendChat и тд..
end
 
  • Нравится
Реакции: G W

meowprd

Тот самый Котовский
Проверенный
1,280
712
Lua:
local hook = require 'lib.samp.events'
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
end

function hook.onServerMessage(color, text)
    if text:find("Жалоба от игрока") then
        local id = text:match("Жалоба от игрока .*%[(%d+)%]%: Тест")
        sampSendChat("/ap "..id.." test")
    end
end
 
  • Нравится
Реакции: G W

G W

Участник
Автор темы
141
5
Lua:
local hook = require 'lib.samp.events'
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
end

function hook.onServerMessage(color, text)
    if text:find("Жалоба от игрока") then
        local id = text:match("Жалоба от игрока .*%[(%d+)%]%: Тест")
        sampSendChat("/ap "..id.." test")
    end
end

Ошибку выбивает. В чем проблема опять ? :(
Код:
[14:01:57.398906] (system)    Session started.
[14:01:57.400906] (debug)    Module handle: 6B700000

MoonLoader v.026.5-beta loaded.
Developers: FYP, hnnssy, EvgeN 1137

Copyright (c) 2016, BlastHack Team
https://www.blast.hk/moonloader/

[14:01:57.400906] (info)    Working directory: D:\Clear GTA SAMP low PC\moonloader
[14:01:57.400906] (debug)    FP Control: 0009001F
[14:01:57.400906] (debug)    Game: UNKNOWN GAME
[14:01:57.788928] (system)    Installing pre-game hooks...
[14:01:57.796929] (system)    Hooks installed.
[14:02:05.901392] (debug)    Initializing opcode handler table
[14:02:05.902392] (debug)    package.path = D:\Clear GTA SAMP low PC\moonloader\lib\?.lua;D:\Clear GTA SAMP low PC\moonloader\lib\?\init.lua;D:\Clear GTA SAMP low PC\moonloader\?.lua;D:\Clear GTA SAMP low PC\moonloader\?\init.lua;.\?.lua;D:\Clear GTA SAMP low PC\moonloader\lib\?.luac;D:\Clear GTA SAMP low PC\moonloader\lib\?\init.luac;D:\Clear GTA SAMP low PC\moonloader\?.luac;D:\Clear GTA SAMP low PC\moonloader\?\init.luac;.\?.luac
[14:02:05.902392] (debug)    package.cpath = D:\Clear GTA SAMP low PC\moonloader\lib\?.dll;
[14:02:05.908393] (system)    Loading script 'D:\Clear GTA SAMP low PC\moonloader\AutoReboot.lua'...
[14:02:05.908393] (debug)    New script: 01A22714
[14:02:05.912393] (system)    ML-AutoReboot: Loaded successfully.
[14:02:05.913393] (system)    Loading script 'D:\Clear GTA SAMP low PC\moonloader\dialog_imgui.lua'...
[14:02:05.913393] (debug)    New script: 01A247A4
[14:02:06.207410] (system)    dialog_imgui.lua: Loaded successfully.
[14:02:06.207410] (system)    Loading script 'D:\Clear GTA SAMP low PC\moonloader\grp.lua'...
[14:02:06.207410] (debug)    New script: 01A37A94
[14:02:06.388420] (system)    CorrectionWords: Loaded successfully.
[14:02:06.388420] (system)    Loading script 'D:\Clear GTA SAMP low PC\moonloader\reload_all.lua'...
[14:02:06.388420] (debug)    New script: 0A809884
[14:02:06.393420] (system)    ML-ReloadAll: Loaded successfully.
[14:02:06.393420] (system)    Loading script 'D:\Clear GTA SAMP low PC\moonloader\SF Integration.lua'...
[14:02:06.393420] (debug)    New script: 0A809A0C
[14:02:06.402421] (system)    SF Integration: Loaded successfully.
[14:02:06.402421] (system)    Loading script 'D:\Clear GTA SAMP low PC\moonloader\zb.lua'...
[14:02:06.402421] (debug)    New script: 0A809B94
[14:02:06.422422] (system)    zb.lua: Loaded successfully.
[14:02:32.953940] (system)    Installing post-load hooks...
[14:02:32.953940] (system)    Hooks installed.
[14:03:11.256130] (error)    zb.lua: D:\Clear GTA SAMP low PC\moonloader\zb.lua:10: attempt to concatenate local 'id' (a nil value)
stack traceback:
    D:\Clear GTA SAMP low PC\moonloader\zb.lua:10: in function 'callback'
    ...lear GTA SAMP low PC\moonloader\lib\samp\events\core.lua:77: in function 'process_event'
    ...lear GTA SAMP low PC\moonloader\lib\samp\events\core.lua:100: in function 'process_packet'
    ...lear GTA SAMP low PC\moonloader\lib\samp\events\core.lua:127: in function <...lear GTA SAMP low PC\moonloader\lib\samp\events\core.lua:126>
[14:03:11.260131] (error)    zb.lua: D:\Clear GTA SAMP low PC\moonloader\zb.lua:10: attempt to concatenate local 'id' (a nil value)
stack traceback:
    D:\Clear GTA SAMP low PC\moonloader\zb.lua:10: in function 'callback'
    ...lear GTA SAMP low PC\moonloader\lib\samp\events\core.lua:77: in function 'process_event'
    ...lear GTA SAMP low PC\moonloader\lib\samp\events\core.lua:100: in function 'process_packet'
    ...lear GTA SAMP low PC\moonloader\lib\samp\events\core.lua:127: in function <...lear GTA SAMP low PC\moonloader\lib\samp\events\core.lua:126>
[14:03:11.265131] (error)    zb.lua: Script died due to an error. (0A809B94)
 

meowprd

Тот самый Котовский
Проверенный
1,280
712
Ошибку выбивает. В чем проблема опять ? :(
Код:
[14:01:57.398906] (system)    Session started.
[14:01:57.400906] (debug)    Module handle: 6B700000

MoonLoader v.026.5-beta loaded.
Developers: FYP, hnnssy, EvgeN 1137

Copyright (c) 2016, BlastHack Team
https://www.blast.hk/moonloader/

[14:01:57.400906] (info)    Working directory: D:\Clear GTA SAMP low PC\moonloader
[14:01:57.400906] (debug)    FP Control: 0009001F
[14:01:57.400906] (debug)    Game: UNKNOWN GAME
[14:01:57.788928] (system)    Installing pre-game hooks...
[14:01:57.796929] (system)    Hooks installed.
[14:02:05.901392] (debug)    Initializing opcode handler table
[14:02:05.902392] (debug)    package.path = D:\Clear GTA SAMP low PC\moonloader\lib\?.lua;D:\Clear GTA SAMP low PC\moonloader\lib\?\init.lua;D:\Clear GTA SAMP low PC\moonloader\?.lua;D:\Clear GTA SAMP low PC\moonloader\?\init.lua;.\?.lua;D:\Clear GTA SAMP low PC\moonloader\lib\?.luac;D:\Clear GTA SAMP low PC\moonloader\lib\?\init.luac;D:\Clear GTA SAMP low PC\moonloader\?.luac;D:\Clear GTA SAMP low PC\moonloader\?\init.luac;.\?.luac
[14:02:05.902392] (debug)    package.cpath = D:\Clear GTA SAMP low PC\moonloader\lib\?.dll;
[14:02:05.908393] (system)    Loading script 'D:\Clear GTA SAMP low PC\moonloader\AutoReboot.lua'...
[14:02:05.908393] (debug)    New script: 01A22714
[14:02:05.912393] (system)    ML-AutoReboot: Loaded successfully.
[14:02:05.913393] (system)    Loading script 'D:\Clear GTA SAMP low PC\moonloader\dialog_imgui.lua'...
[14:02:05.913393] (debug)    New script: 01A247A4
[14:02:06.207410] (system)    dialog_imgui.lua: Loaded successfully.
[14:02:06.207410] (system)    Loading script 'D:\Clear GTA SAMP low PC\moonloader\grp.lua'...
[14:02:06.207410] (debug)    New script: 01A37A94
[14:02:06.388420] (system)    CorrectionWords: Loaded successfully.
[14:02:06.388420] (system)    Loading script 'D:\Clear GTA SAMP low PC\moonloader\reload_all.lua'...
[14:02:06.388420] (debug)    New script: 0A809884
[14:02:06.393420] (system)    ML-ReloadAll: Loaded successfully.
[14:02:06.393420] (system)    Loading script 'D:\Clear GTA SAMP low PC\moonloader\SF Integration.lua'...
[14:02:06.393420] (debug)    New script: 0A809A0C
[14:02:06.402421] (system)    SF Integration: Loaded successfully.
[14:02:06.402421] (system)    Loading script 'D:\Clear GTA SAMP low PC\moonloader\zb.lua'...
[14:02:06.402421] (debug)    New script: 0A809B94
[14:02:06.422422] (system)    zb.lua: Loaded successfully.
[14:02:32.953940] (system)    Installing post-load hooks...
[14:02:32.953940] (system)    Hooks installed.
[14:03:11.256130] (error)    zb.lua: D:\Clear GTA SAMP low PC\moonloader\zb.lua:10: attempt to concatenate local 'id' (a nil value)
stack traceback:
    D:\Clear GTA SAMP low PC\moonloader\zb.lua:10: in function 'callback'
    ...lear GTA SAMP low PC\moonloader\lib\samp\events\core.lua:77: in function 'process_event'
    ...lear GTA SAMP low PC\moonloader\lib\samp\events\core.lua:100: in function 'process_packet'
    ...lear GTA SAMP low PC\moonloader\lib\samp\events\core.lua:127: in function <...lear GTA SAMP low PC\moonloader\lib\samp\events\core.lua:126>
[14:03:11.260131] (error)    zb.lua: D:\Clear GTA SAMP low PC\moonloader\zb.lua:10: attempt to concatenate local 'id' (a nil value)
stack traceback:
    D:\Clear GTA SAMP low PC\moonloader\zb.lua:10: in function 'callback'
    ...lear GTA SAMP low PC\moonloader\lib\samp\events\core.lua:77: in function 'process_event'
    ...lear GTA SAMP low PC\moonloader\lib\samp\events\core.lua:100: in function 'process_packet'
    ...lear GTA SAMP low PC\moonloader\lib\samp\events\core.lua:127: in function <...lear GTA SAMP low PC\moonloader\lib\samp\events\core.lua:126>
[14:03:11.265131] (error)    zb.lua: Script died due to an error. (0A809B94)
Видимо я неправильно написал регулярное выражение.
Сейчас чекну, если неправильно - перепишу

Update:
Lua:
function hook.onServerMessage(color, text)
    if text:find("Жалоба от игрока") then
        sampAddChatMessage("Хукнул сообщение", -1)
        local id, t = text:match("Жалоба от игрока .*%[(%d+)%]: (.*)")
        if t == 'Тест' then sampSendChat("/ap "..id.." test") end
    end
end

Проверь.
Если текст жалобы будет "Тест", то отправит /ad id test
 
Последнее редактирование:
  • Нравится
Реакции: G W

G W

Участник
Автор темы
141
5
Видимо я неправильно написал регулярное выражение.
Сейчас чекну, если неправильно - перепишу

Update:
Lua:
function hook.onServerMessage(color, text)
    if text:find("Жалоба от игрока") then
        sampAddChatMessage("Хукнул сообщение", -1)
        local id, t = text:match("Жалоба от игрока .*%[(%d+)%]: (.*)")
        if t == 'Тест' then sampSendChat("/ap "..id.." test") end
    end
end

Проверь.
Если текст жалобы будет "Тест", то отправит /ad id test
К огромному сожалению не работает. У Вас она работает ? Проверяли ? Может я такой, что, мне не везет. :(
 

meowprd

Тот самый Котовский
Проверенный
1,280
712
К огромному сожалению не работает. У Вас она работает ? Проверяли ? Может я такой, что, мне не везет. :(
У себя проверял - работает.
Проверь сф консоль, может скрипт крашится?
В чат пишет, что хукнул сообщение?
 
  • Нравится
Реакции: G W

G W

Участник
Автор темы
141
5
У себя проверял - работает.
Проверь сф консоль, может скрипт крашится?
В чат пишет, что хукнул сообщение?
Да, пишет, но ответ игроку не отправляется. Сейчас посмотрю консоль.
 

meowprd

Тот самый Котовский
Проверенный
1,280
712
Да, пишет, но ответ игроку не отправляется. Сейчас посмотрю консоль.
Текст должен быть обязательно "Тест"
Ни точки, ни пробела лишнего, ничего не должно быть.
Это же автоответчик.
 
  • Влюблен
Реакции: G W