Не работает скрипт

lightmetal

Участник
Автор темы
32
3
Версия MoonLoader
.026-beta
Подскажите почему не работает скрипт. Когда в чате пишут псж/psj/увал/увал псж/увольте, то должно вылазить оповещение о принятии формы об увольнении игрока. Если принимается - увал,если нет, то форма отменяется. Но почему то он даже не видит собщений в чате
Код:
local ev=require "lib.samp.events"
require 'moonloader'
local msguval = {
    'псж',
    'psj',
    'увал',
    'увал псж',
    'увольте',
    
}
function sampev.onServerMessage(color, text)
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
        if text:find('%[F%] .+ (.+)%[(.+)%]: (.+)') then
            local nick, id, textmsg = text:match('%[F%] .+ (.+)%[(.+)%]: (.+)')
            for k, v in ipairs(msguval) do
                if textmsg:lower():find(v) then
                    msg(nick..' Хочет уйти по собственному желанию. Нажмите + для одобрения или - для отказа.')
                    lasttime = os.time()
                    lasttimes = 0
                    time_out = 5
                    lua_thread.create(function()
                        while lasttimes < time_out do
                            lasttimes = os.time() - lasttime
                            wait(0)
                            printStyledString("PSJ  "..nick..' ' .. time_out - lasttimes .. " WAIT", 1000, 4)
                            if isKeyJustPressed(0xBB) then
                                printStyledString("Accept Form", 1000, 4)
                                sampSendChat('/uninvite '..id..' ПСЖ')
                                msg(nick..' Был уволен ПСЖ.', -2)
                                break
                            end
                            if isKeyJustPressed(0xBD) then
                                printStyledString("Skipped Form", 1000, 4)
                                break
                            end
                        end
                    end)
                end
            end
        end
    end
 

MLycoris

Режим чтения
Проверенный
1,831
1,901
писал чот похожее давненько, попробуй
Lua:
local sampev = require('lib.samp.events')
local words = {'псж','psj','увал','увольте'}
local font = renderCreateFont('TimesNewRoman', 12, 5)
local st = {
    nick = '',
    bool = false,
    timer = -1,
    id = -1,
}

function main()
    while true do wait(0)
        if st.bool and st.timer ~= -1 then
            timer = os.clock()-st.timer
            renderFontDrawText(font,'Нажми Y чтоб уволить '..st.nick..' или N чтоб не увольнять\nВремени на раздумья 6 сек, прошло: '..tostring(os.date("!*t", timer).sec), 500, 500, 0xFFFFFFFF)
            if timer > 5 or wasKeyPressed(0x59) or wasKeyPressed(0x4E) then
                if wasKeyPressed(0x59) then
                    sampSendChat('/uninvite '..st.id..' ПСЖ')
                end
                st.bool = false
                st.timer = -1
            end
        end
    end
end
function sampev.onServerMessage(color, text)
    for k, v in pairs(words) do
        local nick, id, msg = text:match('%[F%] (.+)%[(%d+)%]: (.+)')
        if nick and id and msg:find(v) then
            st.nick = nick
            st.id = id
            st.bool = true
            st.timer = os.clock()
        end
    end
end
 

lightmetal

Участник
Автор темы
32
3
скрипт может в целом не работать лишь при одном условии, он пустой блять... moonloader.log скинь 🤦‍♂️

E:\gta #skayfom\moonloader\uval.lua:18: in main chunk
[23:34:11.707284] (error) uval.lua: Script died due to an error. (06BB4B84)
[23:34:26.536283] (system) Installing post-load hooks...
[23:34:26.536283] (system) Hooks installed.


писал чот похожее давненько, попробуй
Lua:
local sampev = require('lib.samp.events')
local words = {'псж','psj','увал','увольте'}
local font = renderCreateFont('TimesNewRoman', 12, 5)
local st = {
    nick = '',
    bool = false,
    timer = -1,
    id = -1,
}

function main()
    while true do wait(0)
        if st.bool and st.timer ~= -1 then
            timer = os.clock()-st.timer
            renderFontDrawText(font,'Нажми Y чтоб уволить '..st.nick..' или N чтоб не увольнять\nВремени на раздумья 6 сек, прошло: '..tostring(os.date("!*t", timer).sec), 500, 500, 0xFFFFFFFF)
            if timer > 5 or wasKeyPressed(0x59) or wasKeyPressed(0x4E) then
                if wasKeyPressed(0x59) then
                    sampSendChat('/uninvite '..st.id..' ПСЖ')
                end
                st.bool = false
                st.timer = -1
            end
        end
    end
end
function sampev.onServerMessage(color, text)
    for k, v in pairs(words) do
        local nick, id, msg = text:match('%[F%] (.+)%[(%d+)%]: (.+)')
        if nick and id and msg:find(v) then
            st.nick = nick
            st.id = id
            st.bool = true
            st.timer = os.clock()
        end
    end
end
Ничего не происходит
 

MLycoris

Режим чтения
Проверенный
1,831
1,901

Вложения

  • 1test.lua
    1.6 KB · Просмотры: 2