принятие формы

calculatorxss

Новичок
Автор темы
15
2
Версия MoonLoader
.026-beta
Короче, увидел на форуме скрипт с авто-принятием форм с админ чата, и захотел себе такой же на мод авроры рп.
Что-то сделал, но все равно не пашет, помогите
Вот код
Lua:
local sampev = require 'lib.samp.events'

local active_forma = false
local stop_forma = false

local allForms = {"kick", "mute", "jail","sethp","gspawn", "slap", "unmute", "unjail", "sban",  "ban", "sban", "warn", "skick", "ao", "unban", "unwarn", "setskin", "skick", "banip", "offban", "offwarn", "plveh", "sban","ao", "givegun"}

function main()
    while not isSampLoaded() do wait(100) end
    while true do
        wait(0)
    end
end

function sampev.onServerMessage(clr, text)
    if active_forma then
        if text:find('%(.*%) (%w+_?%w+)%[(%d+)%]%: [Forma] +') then
            printStyledString("Form skipped", 1000, 4)
            active_forma = false
            stop_forma = true
        end
    end
    for k,v in ipairs(allForms) do
        if text:match("%[.*%] "..getMyNick().."%["..getMyId().."%]%: /"..v.."%s") then
            return true
        else
            if text:match("%(.*%) (%w+_?%w+)%[(%d+)%]%: /"..v.."%s") then
                admin_nick, admin_id, admin_other = text:match("%[.*%] (%w+_?%w+)%[(%d+)%]%: /"..v.."%s(.*)")
                sampAddChatMessage('{FF0000}[Info] {FF8C00}Пришла форма, чтобы принять ее нажмите >> K << | Чтобы отклонить >> P <<', 0xFFFF0000)
                active_forma = true
                cmd = v
                forma()
            end
        end
    end
end

function forma()
    if active_forma then
        lua_thread.create(function()
            lasttime = os.time()
            lasttimes = 0
            time_out = 10
            while lasttimes < time_out do
                lasttimes = os.time() - lasttime
                wait(0)
                printStyledString("ADMIN FORM " .. time_out - lasttimes .. " WAIT", 1000, 4)
                if lasttimes == time_out then
                    active_forma = false
                    printStyledString("Forma skipped", 1000, 4)
                end
                if isKeyJustPressed(VK_K) and not sampIsChatInputActive() and not sampIsDialogActive() then
                    printStyledString("Admin form accepted", 1000, 4)
                    sampSendChat("/"..cmd.." "..admin_other.." || "..admin_nick)
                    wait(1000)
                    sampSendChat('/a [Forma] +')
                    --lasttimes = 11
                    active_forma = false
                elseif isKeyJustPressed(VK_P) and not sampIsChatInputActive() and not sampIsDialogActive() then
                    printStyledString('You missed the form', 1000, 4)
                    --lasttimes = 11
                    active_forma = false
                end
                if stop_forma then
                    --lasttimes = 11
                    active_forma = false
                    break
                end
            end
        end)
    else   
        if isKeyJustPressed(VK_P) and not sampIsChatInputActive() and not sampIsDialogActive() then
            printStyledString('You can’t skip the form temporarily', 1000, 4)
        end
    end
end

function getMyNick()
    local result, id = sampGetPlayerIdByCharHandle(playerPed)
    if result then
        local nick = sampGetPlayerNickname(id)
        return nick
    end
end

function getMyId()
    local result, id = sampGetPlayerIdByCharHandle(playerPed)
    if result then
        return id
    end
end

Вот чат лог админ чата
[A] {008000}(Администратор){FFFFFF} {FFFFFF}Artemich_Calculator(62): 123