Devil HunterDevil Docs
Payment In Game

ระบบการันตี (สะสมยอด)

ตั้งค่าระบบสะสมยอดซื้อเพื่อรับรางวัล แบบรีเซ็ตและสะสมต่อ

ระบบ Guarantee คือระบบสะสมยอดซื้อ — ผู้เล่นซื้อสินค้าสะสมไปเรื่อย ๆ พอถึงยอดที่กำหนดแล้วจะได้รางวัล เหมาะสำหรับสร้างแรงจูงใจให้ซื้อซ้ำ

หลักการ

ระบบจะนับยอดซื้อของแต่ละสินค้าแยกกัน พอยอดสะสมถึง amount ของแต่ละ tier ผู้เล่นจะได้รับ reward อัตโนมัติ หรือกดรับเองใน UI

ตั้งค่าระบบ Guarantee บนสินค้า

เพิ่ม guarantee block ลงในสินค้าใน config_main.lua:

config_main.lua
{
    label = "Bread",
    price = 15,
    pointPrice = 15,
    description = "ขนมปัง",
    earnPoints = 1,
    type = "item",
    spawnName = "bread",
    limitId = { enabled = false, id = "bread_basic" },

    -- ระบบการันตี
    guarantee = {
        enabled = true,
        resetOnClaim = false,    -- false = สะสมต่อหลังรับครบ | true = รีเซ็ต

        tiers = {
            {
                amount = 100,     -- สะสมครบ 100 Point แล้วรับ
                description = "ครบ 100 Point",
                reward = {
                    name = "water",
                    count = 1,
                    label = "Water x1"
                }
            },
            {
                amount = 500,     -- สะสมครบ 500 Point แล้วรับ
                description = "ครบ 500 Point",
                reward = {
                    name = "water",
                    count = 5,
                    label = "Water x5"
                }
            },
            {
                amount = 2000,    -- สะสมครบ 2000 Point แล้วรับ
                description = "ครบ 2,000 Point",
                reward = {
                    name = "water",
                    count = 12,
                    label = "Water x12"
                }
            },
        },
    },
}

resetOnClaim: สะสมต่อ vs รีเซ็ต

config_main.lua
guarantee = {
    enabled = true,
    resetOnClaim = false,
    tiers = { ... }
}

หลักการ:

  • ผู้เล่นสะสมยอดไปเรื่อย ๆ
  • ถึง tier 1 (100) → รับ Water x1
  • ถึง tier 2 (500) → รับ Water x5
  • ถึง tier 3 (2000) → รับ Water x12
  • หลังครบทุก tier ยอดยังคงอยู่ — เหมาะถ้าคุณจะเพิ่ม tier ใหม่ในอนาคต หรืออยากให้ผู้เล่นรู้สึกว่ายอดไม่หาย
config_main.lua
guarantee = {
    enabled = true,
    resetOnClaim = true,
    tiers = { ... }
}

หลักการ:

  • ผู้เล่นสะสมครบทุก tier แล้วรับครบ
  • ยอดสะสมจะรีเซ็ตเป็น 0 — เริ่มสะสมใหม่
  • เหมาะสำหรับระบบรายเดือน/รายสัปดาห์ ที่อยากให้วนลูป

ตัวอย่างรูปแบบ reward

ไอเทมธรรมดา

config_main.lua
reward = {
    name = "water",           -- ชื่อใน nc_inventory
    count = 5,                -- จำนวน
    label = "Water x5"        -- ป้ายที่แสดงใน UI
}

ไอเทมหายาก

config_main.lua
reward = {
    name = "gold_bar",
    count = 1,
    label = "Gold Bar (หายาก)"
}

ยานพาหนะ (รางวัลใหญ่)

config_main.lua
{
    amount = 50000,
    description = "ครบ 50,000 Point",
    reward = {
        name = "sultan",
        count = 1,
        label = "Sultan RS (รถรางวัล)"
    }
}

Hook: แจ้งเตือนตอนรับรางวัล

ใช้ OnGuaranteeClaim ใน config_function_server.lua เพื่อแจ้งเตือนเมื่อผู้เล่นรับรางวัลการันตี:

config_function_server.lua
Config_Function.OnGuaranteeClaim = function(xPlayer, itemKey, tierAmount, reward)
    -- xPlayer = ข้อมูลผู้เล่น
    -- itemKey = key สินค้าที่สะสม
    -- tierAmount = ยอด tier ที่ถึง
    -- reward = { name, count, label }

    -- ส่ง webhook แจ้งแอดมิน
    local playerName = GetPlayerName(xPlayer.source)
    PerformHttpRequest('https://your-webhook-url', function(err, text, headers) end, 'POST',
        json.encode({
            content = playerName .. ' รับรางวัลการันตี: ' .. reward.label .. ' (ยอดสะสม ' .. tierAmount .. ')'
        }),
        { ['Content-Type'] = 'application/json' })
end

ตรวจสอบยอดสะสม

ดูยอดสะสมการันตีของผู้เล่นผ่านคำสั่งแอดมิน (ถ้ามี) หรือตรวจในฐานข้อมูล:

guarantee_progress.sql
-- ดูยอดสะสมของผู้เล่นทั้งหมด (ตารางจริงอาจต่างไปตามเวอร์ชัน)
SELECT identifier, item_key, total_amount, claimed_tiers
FROM devil_guarantee_progress
WHERE identifier = 'char1:123456';

รางวัลต้องมีในระบบจริง

reward.name ต้องเป็นไอเทมที่มีใน nc_inventory จริง ๆ มิฉะนั้นผู้เล่นรับรางวัลแล้วจะไม่ได้ของ และระบบจะบันทึกว่า "รับแล้ว" ทำให้ไม่สามารถรับซ้ำได้

On this page