Auto Farm

FEATURES - Universal ticket support (learns new ticket types automatically) - Ghost sell / ghost upgrade - remote calls only, zero movement - Draggable, resizable panel with dark UI - Anti-duplicate on re-execute

publiclua [🎟️] Scratch a Ticketupdated
loadstring(game:HttpGet("https://pasteblox.com/raw/dm6nnfjru4"))()
pbx pull dm6nnfjru4raw link never changes · v1 live
auto-farm.lua
-- AutoFarm.lua  (canonical build — always tweak this file)
-- v0.1.10 | Features: AUTO-SCRATCH · GHOST SELL · GHOST UPGRADE
-- made by shark_Attack
-- Pipeline: RequestTicket(Invoke) -> CompleteTicket(Invoke) -> ClaimRevealedReward(Invoke)
-- Executor: Volt | Remote spy: Cobalt

local Players      = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local UserInput    = game:GetService("UserInputService")
local Replicated   = game:GetService("ReplicatedStorage")
local HttpService  = game:GetService("HttpService")
local CoreGui      = game:GetService("CoreGui")

local LP = Players.LocalPlayer

---------------------------------------------------------------------
-- CONFIG
---------------------------------------------------------------------
local Config = {
    Enabled        = false,
    Ticket         = "auto",          -- "auto" = rotate every learned ticket
    Mode           = "Manual",        -- arg 3 of CompleteTicket
    PrizeOverride  = "",              -- "" = use MatchItemId from the server
    Delay          = 0.45,            -- seconds between cycles
    Jitter         = 0.15,
    InvokeTimeout  = 3.0,             -- RemoteFunction wait cap
    SkipIfNoPrize  = true,            -- do not blind-send a prize we don't know
    UpgradeTarget  = "",              -- "" off | "Luck" | "Value" | "Both"
    UpgradeDelay   = 2.0,             -- seconds between auto-upgrade attempts
    ToggleKey      = Enum.KeyCode.F,
    StatsRefresh   = 0.35,
}
getgenv().V_Scratch = Config

local Stats = {
    cycles = 0, rewards = 0, fails = 0,
    startedAt = os.clock(), status = "Idle",
    lastGuid = "-", lastPrize = "-", lastGrant = "-",
}

local log  -- assigned once the log panel exists

---------------------------------------------------------------------
-- REMOTES
---------------------------------------------------------------------
local Remotes = { request = nil, complete = nil, claim = nil, index = nil, sellAll = nil, upgrade = nil, upState = nil, reward = nil }

local function findByRemoteName(name, preferFolder)
    local fallback
    for _, v in ipairs(Replicated:GetDescendants()) do
        local isRemote = v:IsA("RemoteEvent") or v:IsA("RemoteFunction")
        if isRemote and v.Name == name then
            if preferFolder and v.Parent and v.Parent.Name:find(preferFolder) then
                return v
            end
            fallback = fallback or v
        end
    end
    return fallback
end

local function resolveRemotes()
    Remotes.request  = findByRemoteName("RequestTicket", "Scratch")
    Remotes.complete = findByRemoteName("CompleteTicket", "Scratch")
    Remotes.claim    = findByRemoteName("ClaimRevealedReward", "Scratch")
    Remotes.index    = findByRemoteName("GetIndexData")
    Remotes.sellAll  = findByRemoteName("SellAll", "Sell")
    Remotes.upgrade  = findByRemoteName("BuyUpgrade", "Upgrade")
    Remotes.upState  = findByRemoteName("GetUpgradeState", "Upgrade")
    Remotes.reward   = findByRemoteName("RewardGranted")
end
resolveRemotes()

---------------------------------------------------------------------
-- TICKET TYPES (universal)
---------------------------------------------------------------------
local TicketList = { "BasicTicket" }
local learned = { BasicTicket = true }
local ticketIdx = 0

local function learnTicket(name)
    if type(name) ~= "string" then return end
    if #name > 40 or not name:lower():find("ticket") then return end
    if learned[name] then return end
    learned[name] = true
    table.insert(TicketList, name)
    if log then log("learned ticket: " .. name) end
end

local function nextTicket()
    if Config.Ticket ~= "auto" then return Config.Ticket end
    if #TicketList == 0 then return "BasicTicket" end
    ticketIdx = (ticketIdx % #TicketList) + 1
    return TicketList[ticketIdx]
end

-- learn every ticket name the game itself fires when you click one
if hookmetamethod and getnamecallmethod then
    pcall(function()
        local old
        old = hookmetamethod(game, "__namecall", function(self, ...)
            local method = getnamecallmethod()
            if method == "InvokeServer" and typeof(self) == "Instance"
                and self.Name == "RequestTicket" then
                learnTicket((...))
            end
            return old(self, ...)
        end)
    end)
end

---------------------------------------------------------------------
-- REMOTE HELPERS
---------------------------------------------------------------------
local function invoke(remote, timeout, ...)
    if not remote then return false, nil, "no remote" end
    local done, ok, value, err = false, false, nil, nil
    local args = table.pack(...)

    task.spawn(function()
        local s, r = pcall(function()
            if remote:IsA("RemoteFunction") then
                return remote:InvokeServer(table.unpack(args, 1, args.n))
            end
            remote:FireServer(table.unpack(args, 1, args.n))
            return nil
        end)
        ok, value = s, r
        if not s then err = tostring(r) end
        done = true
    end)

    local t0 = os.clock()
    while not done and (os.clock() - t0) < timeout do
        task.wait(0.03)
    end
    return done and ok, value, err
end

-- pull fields out of whatever table the server returns
local function findField(t, names, depth)
    depth = depth or 0
    if type(t) ~= "table" or depth > 3 then return nil end
    -- name priority first, so MatchItemId wins over generic "Id"
    for _, n in ipairs(names) do
        for k, v in pairs(t) do
            if type(k) == "string" and k:lower() == n:lower()
                and (type(v) == "string" or type(v) == "number") then
                local s = tostring(v)
                if s ~= "" then return s end
            end
        end
    end
    for _, v in pairs(t) do
        if type(v) == "table" then
            local r = findField(v, names, depth + 1)
            if r then return r end
        end
    end
end

local GUID_KEYS  = { "TicketId", "Uuid", "Guid", "Ticket", "Token", "CardId", "Key", "Id" }
local PRIZE_KEYS = { "MatchItemId", "Prize", "Reward", "Item", "Result", "Loot", "Name", "Value" }
local GRANT_KEYS = { "GrantId", "Grant", "Id" }

local function parseRequest(res)
    if type(res) == "string" then
        return res, nil
    end
    if type(res) == "table" then
        return findField(res, GUID_KEYS), findField(res, PRIZE_KEYS)
    end
    return nil, nil
end

---------------------------------------------------------------------
-- SCRATCH ENGINE
---------------------------------------------------------------------
local Engine = {}

function Engine.describe(v)
    if type(v) == "table" then
        local ok, s = pcall(function() return HttpService:JSONEncode(v) end)
        if ok and #s < 1200 then return s end
        local parts = {}
        for k, val in pairs(v) do
            table.insert(parts, tostring(k) .. "=" .. tostring(val))
            if #parts >= 10 then break end
        end
        return "{" .. table.concat(parts, ", ") .. "}"
    end
    return tostring(v)
end

-- one full ticket cycle; returns true on success
function Engine.cycle(verbose)
    if not Remotes.request then return false, "RequestTicket missing" end

    local ticket = nextTicket()
    Config.LastTicket = ticket

    local ok, res, err = invoke(Remotes.request, Config.InvokeTimeout, ticket, true, true)
    if not ok then return false, "RequestTicket failed: " .. tostring(err) end
    if verbose then
        log("request -> " .. Engine.describe(res))
        pcall(function() print("[V] request raw: " .. HttpService:JSONEncode(res)) end)
    end

    local guid, prize = parseRequest(res)
    if not guid then
        -- server often hands back nothing; the client mints the ticket id itself
        guid = HttpService:GenerateGUID(false):lower()
        if verbose then log("no server id — minted " .. guid) end
    end
    Stats.lastGuid = guid

    local finalPrize = (Config.PrizeOverride ~= "" and Config.PrizeOverride) or prize
    Stats.lastPrize = finalPrize or "-"

    if not finalPrize and Config.SkipIfNoPrize then
        return false, "prize unknown (set Prize override)"
    end

    if Remotes.complete then
        local cok, cres = invoke(Remotes.complete, Config.InvokeTimeout, guid, finalPrize, Config.Mode)
        if not cok then return false, "CompleteTicket failed" end
        if verbose then log("complete -> " .. Engine.describe(cres)) end

        -- claim is keyed to the GrantId that complete returns, not the ticket id
        local grant = (type(cres) == "table" and findField(cres, GRANT_KEYS)) or nil
        if grant then Stats.lastGrant = grant end

        if Remotes.claim then
            local clok, clres = invoke(Remotes.claim, Config.InvokeTimeout, grant or guid)
            if not clok then return false, "Claim failed" end
            if verbose then log("claim -> " .. Engine.describe(clres)) end
        end
    end

    return true, "ok"
end

-- ghost sell: same call the game makes, no walking to the sell pad
function Engine.sellAll()
    if not Remotes.sellAll then return false, "SellAll remote missing" end
    local ok, res, err = invoke(Remotes.sellAll, Config.InvokeTimeout)
    if not ok then return false, "sell failed: " .. tostring(err) end
    return true, Engine.describe(res)
end

-- ghost upgrade: BuyUpgrade(<name>, 1) straight from the client
function Engine.upgrade(name)
    if not Remotes.upgrade then return false, "BuyUpgrade remote missing" end
    if not name or name == "" then return false, "no upgrade selected" end
    local ok, res, err = invoke(Remotes.upgrade, Config.InvokeTimeout, name, 1)
    if not ok then return false, "upgrade failed: " .. tostring(err) end
    return true, Engine.describe(res)
end

function Engine.upgradeTargets()
    if Config.UpgradeTarget == "Both" then return { "Luck", "Value" } end
    if Config.UpgradeTarget ~= "" then return { Config.UpgradeTarget } end
    return {}
end

function Engine.loop()
    while task.wait() do
        if not Config.Enabled then
            Stats.status = "Idle"
            task.wait(0.15)
        else
            local ok, reason = Engine.cycle(false)
            if ok then
                Stats.cycles = Stats.cycles + 1
                Stats.status = "Cycle " .. Stats.cycles .. " | " .. Stats.lastPrize
            else
                Stats.fails = Stats.fails + 1
                Stats.status = "Stopped: " .. tostring(reason)
            end

            task.wait(Config.Delay + math.random() * Config.Jitter)
        end
    end
end

if Remotes.reward then
    pcall(function()
        Remotes.reward.OnClientEvent:Connect(function()
            Stats.rewards = Stats.rewards + 1
        end)
    end)
end

-- auto upgrade loop: independent of the scratch loop
task.spawn(function()
    local last = 0
    local lastFail = nil
    while task.wait(0.4) do
        if Remotes.upgrade and Config.UpgradeTarget ~= "" and (os.clock() - last) >= Config.UpgradeDelay then
            last = os.clock()
lines 1–300 of 879open raw find-in-page only searches the lines loaded so far. "show all" loads the rest.

changelog

1 version
  1. first version

    live

    @drgdrgdrgdr_23402·