Retrieve offers

This page gives information about how to get a AI in-game shop offer from TentuPlay database. You will learn the following:

  • The prerequisites that are required

  • Module, classes, and methods that are applicable

  • How to get an AI offer data

Prerequisites

This page assumes that you are finished with the following:

Module, class, and methods in use

When ShowOfferById or ShowLatestOffer is called, TPPersonalizedOffer module will dynamically retrieve offers by player (namely, userId) and returns you the data table for your use.

  • ShowOfferById and ShowLatestOffer are methods of the TPPersonalizedOffer module.

  • TPPersonalizedOffer is a module for retrieving TentuPlay Personalized Offers and AI In-Game Shop offers

Request an offer

  1. Call ShowOfferById or ShowLatestOffer by using TPPersonalizedOffer module’s function as shown in the code example.

    Code example
    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local TentuplaySDKModules = ReplicatedStorage["tentuplay-sdk-modules-ReplicatedStorage"]
    
    local TPPersonalizedOffer = require(TentuplaySDKModules.TPPersonalizedOffer)
    
    function showPersonalizedOffer()
    	while true do
    		wait(5)
    		local response = TPPersonalizedOffer.GetOffersAsync(player.UserId)
    		for _, offer in pairs(response) do
    			local offerByIdCallback = TPPersonalizedOffer.ShowOfferById(player.UserId,"EN", offer.offer_id)
    		end
    	end
    end
    
    local personalizedOfferCoroutine = coroutine.create(showPersonalizedOffer)
    coroutine.resume(personalizedOfferCoroutine)
  2. Now, the offer appears on the screen

    300