Devil HunterDevil Docs
Payment In Game

ระบบตรวจจับพฤติกรรมผิดปกติ

ระบบตรวจจับพฤติกรรมผิดปกติจากผู้เล่น (config_suspects.lua)

ไฟล์ config_suspects.lua ตั้งค่าระบบตรวจจับการโกงหรือการดัดแปลงค่าจากฝั่งผู้เล่น (client-side tampering)

ระบบตรวจจับทั้งหมด

1. Negative Price Detection

ตรวจจับการส่งราคาติดลบหรือค่าผิดรูปแบบเข้ามาจาก client

config_suspects.lua
Suspects.negativePriceDetect = {
    dropEnable = false,                        -- true = เตะผู้เล่นเมื่อเจอเคสนี้
    discordLogHookUrl = "ลิงค์ดิสคอร์ด webhook",

    detected = function(source, xPlayer)
        -- จัดการเมื่อเจอเคส
    end
}

2. Invalid Quantity Detection

ตรวจจับการซื้อจำนวนผิดปกติ เช่น 0, ติดลบ, ทศนิยม, หรือเกินเพดาน

config_suspects.lua
Suspects.invalidQuantityDetect = {
    enabled = true,
    maxQuantityPerPurchase = 100,              -- จำนวนสูงสุดต่อการซื้อ 1 ครั้ง
    detectZeroOrNegative = true,                -- ตรวจจับ 0 หรือค่าติดลบ
    detectNonInteger = true,                    -- ตรวจจับจำนวนที่ไม่ใช่จำนวนเต็ม
    dropEnable = false,
    discordLogHookUrl = "ลิงค์ดิสคอร์ด webhook",
}

3. Item Validation

ตรวจสอบว่าสินค้าที่ client ส่งมามีอยู่จริง และราคาตรงกับ config ฝั่ง server

config_suspects.lua
Suspects.itemValidation = {
    enabled = true,
    validateItemExists = true,                  -- ตรวจว่ามี item/config จริงก่อนซื้อ
    validatePriceMatch = true,                  -- ตรวจว่าราคาตรงกับ config server
    dropEnable = false,
    discordLogHookUrl = "ลิงค์ดิสคอร์ด webhook",
}

4. Session Validation

ตรวจสอบ flow การใช้งาน เช่น ต้องเปิดหน้าร้านก่อนจึงจะสั่งซื้อได้

config_suspects.lua
Suspects.sessionValidation = {
    enabled = true,
    requireMarketOpen = true,                   -- บังคับให้เปิด market ก่อนกดซื้อ
    dropEnable = false,
    discordLogHookUrl = "ลิงค์ดิสคอร์ด webhook",
}

5. Duplicate Transaction Prevention

ป้องกันการยิง event ซื้อซ้ำเร็วเกินไปหรือ spam transaction

config_suspects.lua
Suspects.duplicateTransactionDetect = {
    enabled = true,
    minTimeBetweenPurchases = 300,              -- เวลาขั้นต่ำระหว่างการซื้อ (milliseconds)
    discordLogHookUrl = "ลิงค์ดิสคอร์ด webhook",
}

การตั้งค่า dropEnable

ถ้าตั้งค่า dropEnable = true ระบบจะเตะผู้เล่นออกจากเซิร์ฟเวอร์ทันทีที่ตรวจพบ

ระวังการตั้งค่า dropEnable

คำแนะนำ:

  • เปิดใช้เมื่อมั่นใจว่าการตรวจจับแม่นยำ 100%
  • ถ้ายังอยู่ในช่วงทดสอบ ให้ปิดไว้ก่อน แล้วใช้ discordLogHookUrl เก็บ log
  • ค่า default ของทุกหมวดคือ false เพื่อความปลอดภัย

การเชื่อมต่อ Discord Webhook

ใส่ Webhook URL ในช่อง discordLogHookUrl เพื่อให้ระบบแจ้งเตือนไปยัง Discord เมื่อตรวจพบพฤติกรรมผิดปกติ:

config_suspects.lua
discordLogHookUrl = "https://discord.com/api/webhooks/xxxxx/yyyyy",

แนะนำให้แยกห้อง Discord เฉพาะสำหรับ security log

การปรับแต่งฟังก์ชัน detected

ฟังก์ชัน detected รับ source และ xPlayer (บางหมวดรับ parameter เพิ่ม) สามารถเขียน action เพิ่มได้ เช่น:

config_suspects.lua
detected = function(source, xPlayer, quantity, reason)
    local playerName = source and GetPlayerName(source) or "Unknown"
    print("Invalid quantity detected from " .. playerName)

    -- ตัวอย่าง: เพิ่ม blacklist
    MyBlacklist.Add(source, 'invalid_quantity')

    -- ตัวอย่าง: ส่ง webhook พร้อมข้อมูลเพิ่ม
    local discord = require('discord-webhook')
    discord.send('WEBHOOK_URL', {
        title = 'Invalid Quantity Detected',
        description = 'Player: ' .. playerName .. '\nQty: ' .. tostring(quantity) .. '\nReason: ' .. reason,
        color = 16711680
    })
end

หลักการทำงาน

ระบบนี้ไม่ใช่มาตรการเดียว

ระบบนี้เป็นด่านกันชั้นแรกสำหรับการตรวจจับ client-side tampering ควรใช้ร่วมกับการตรวจสอบข้อมูลฝั่ง server ทุกจุดสำคัญเสมอ

ตัวอย่าง: แม้ว่าจะตรวจจับที่ client แล้ว ฝั่ง server ก็ต้อง validate ซ้ำอีกครั้ง เพราะ hacker อาจ bypass client validation ได้

On this page