Tiers

Overview

The loyalty system provides an export that allows you to check a player's loyalty tier (Silver, Gold, or Platinum) based on their accumulated points. You can use this information to provide tier-based benefits like discounts, exclusive access, or special features.

Export Usage

The loyalty system exposes the following export:

exports['Loyalty']:GetPlayerTier(playerId, function(success, tier)
    -- Your code here
end)

Parameters

  • playerId: The server ID of the player

  • callback: Function that receives two parameters:

    • success: Boolean indicating if the operation was successful

    • tier: String containing the player's tier ("Silver", "Gold", "Platinum") or error message

Example Implementations

1. Basic Shop Discount System

-- In your shop script
function CalculatePrice(playerId, basePrice)
    exports['Loyalty']:GetPlayerTier(playerId, function(success, tier)
        if not success then
            return basePrice -- No discount if error
        end
        
        local discount = 0
        if tier == "Silver" then
            discount = 0.05 -- 5% discount
        elseif tier == "Gold" then
            discount = 0.10 -- 10% discount
        elseif tier == "Platinum" then
            discount = 0.15 -- 15% discount
        end
        
        return basePrice * (1 - discount)
    end)
end

2. VIP Area Access

3. Special Item Access

Important Notes

  1. Tier Names: Always use exact tier names as defined:

    • "Silver"

    • "Gold"

    • "Platinum"

  2. Error Handling: Always check the success parameter before using the tier value:

  1. Asynchronous Operation: The export uses a callback function because it queries the database. Make sure your code handles this asynchronous behavior appropriately.

Tier Thresholds

  • Silver: 0-999 points

  • Gold: 1,000-4,999 points

  • Platinum: 5,000+ points

These thresholds are configured in Config.Tiers and should be considered when designing tier-based features.

Last updated