Help with autosigncheck code

designer

Member
Joined
Apr 3, 2023
Messages
14
Reaction score
0
Location
United States
Is this code right to automate a signcheck or something is missing?

C:
require "lib.moonloader"
local sampev = require 'lib.samp.events'

function main()
    while not isSampAvailable() do wait(0) end
        reset()

    while true do
        wait(100)
        if checkFound then
            sampSendChat("/signcheck")
            if waitForDialog() then
                sampSetCurrentDialogEditboxText(code)
                sampCloseCurrentDialogWithButton(1)
            end
            reset()
        end
    end
end

function waitForDialog()
    local start = os.time()
    while code == "" do
        wait(10)
        if os.difftime(start, os.time()) > 15 then
            return false
        end
    end
    return true
end

function reset()
  code = ""
  checkFound = false
end

function sampev.onServerMessage(colour, msg)
    if (string.find(msg, "You have 5 minutes to sign the check before it becomes invalid.") and not string.find(msg, ":")) then
        checkFound = true
    end
end

function sampev.onShowDialog(dialogId, style, title, button, button2, text)
    if checkFound and string.find(title, "Sign check") then
        code = string.match(text, "%d+")
    end
end
 
Top