Paywalls

To help server owners monetize the AI Emote Creator feature, the kinetix_mod provides two essential methods in the server/paywall.lua file: PaywallBefore and PaywallAfter. These functions enable you to implement checks and enforce payment conditions before and after emote creation.

1. Pre-Paywall Check (PaywallBefore)

This function is triggered before a player generates a QR Code for emote creation. It is where you add your paywall logic, such as checking the player’s balance or usage limit.

Here’s a breakdown:

-- Called before a QR Code request. Add your paywall conditions here
function PaywallBefore(userId, sourceId, callback)
    -- Example: Check player's balance (or other criteria)
    if CheckPlayerBalance(userId) then
        callback() -- Proceed with emote creation
    else
        -- If the player doesn't meet the paywall conditions, send an error
        TriggerClientEvent("paywall_error", sourceId, { 
            title = "Paywall limit", 
            description = "Insufficient funds" 
        })
    end
end

How It Works:

  • You will replace the logic inside CheckPlayerBalance(userId) with your actual code for checking the player’s balance or any other conditions (e.g., subscription tiers, token systems).

  • The callback() function is only called if the player passes the paywall check. If the player does not meet the conditions, do not call the callback() and send a client-side error with TriggerClientEvent instead.

  • The event "paywall_error" is sent to notify the player about paywall restrictions like insufficient funds.

2. Post-Paywall Enforcement (PaywallAfter)

This method is called after the emote generation process has been initiated. This is where you will implement the logic to deduct the player’s balance or track emote creation limits.

Code:

-- Called after a process has been launched. Store your paywall state here
function PaywallAfter(userId, payload)
    -- Example: Deduct the player's balance or increment monthly limit
    DeductPlayerBalance(userId, emotePrice)
end

Explanation:

  • This method is executed after the emote has been generated. You’ll typically use this function to deduct the appropriate currency from the player or track their emote generation usage (e.g., monthly limit).

  • Replace DeductPlayerBalance(userId, emotePrice) with your own balance deduction logic.

Practical Example for Monetization

Let’s say you want to charge 200 diamonds per emote generated. In PaywallBefore, you’d check if the player has at least 200 diamonds in their balance. If they do, callback() is called, allowing them to proceed with emote creation. If they don’t, an error message is sent.

In PaywallAfter, once the emote is created, the player’s balance is deducted by 200 diamonds.

Last updated