Skip to main content

GameProductServiceClient

This item only works when running on the client. Client

This service provides an interface to purchase produces, assets, and other marketplace items. This listens to events, handles requests between server and client, and takes in both assetKeys from GameConfigService, as well as assetIds.

See GameProductService for the server equivalent. The API surface should be effectively the same between the two.

Functions

Init

GameProductServiceClient:Init(serviceBagServiceBag) → ()

Initializes the service. Should be done via ServiceBag

Start

GameProductServiceClient:Start() → ()

Starts the service. Should be done via ServiceBag

ObservePlayerAssetPurchased

GameProductServiceClient:ObservePlayerAssetPurchased(
assetTypeGameConfigAssetType,
idOrKeystring | number
) → Observable<>

Fires when the specified player purchases an asset

ObserveAssetPurchased

GameProductServiceClient:ObserveAssetPurchased(
assetTypeGameConfigAssetType,
idOrKeystring | number
) → Observable<Player>

Fires when any player purchases an asset

HasPlayerPurchasedThisSession

GameProductServiceClient:HasPlayerPurchasedThisSession(
playerPlayer,
assetTypeGameConfigAssetType,
idOrKeystring | number
) → boolean

Returns true if item has been purchased this session

PromisePromptPurchase

GameProductServiceClient:PromisePromptPurchase(
playerPlayer,
assetTypeGameConfigAssetType,
idOrKeystring | number
) → Promise<boolean>

Prompts the user to purchase the asset, and returns true if purchased

PromisePlayerOwnership

GameProductServiceClient:PromisePlayerOwnership(
playerPlayer,
assetTypeGameConfigAssetType,
idOrKeystring | number
) → Promise<boolean>

Returns true if item has been purchased this session

ObservePlayerOwnership

GameProductServiceClient:ObservePlayerOwnership(
playerPlayer,
assetTypeGameConfigAssetType,
idOrKeystring | number
) → Observable<boolean>

Observes if the player owns this cloud asset or not

PromisePlayerIsPromptOpen

GameProductServiceClient:PromisePlayerIsPromptOpen(playerPlayer) → Promise<boolean>

Returns true if the prompt is open

PromisePlayerPromptClosed

GameProductServiceClient:PromisePlayerPromptClosed(playerPlayer) → Promise

Returns a promise that will resolve when all prompts are closed

PromisePlayerOwnershipOrPrompt

GameProductServiceClient:PromisePlayerOwnershipOrPrompt(
playerPlayer,
assetTypeGameConfigAssetType,
idOrKeystring | number
) → Promise<boolean>

Checks if the asset is ownable and if it is, checks player ownership. Otherwise, it checks if the asset has been purchased this session. If the asset has not been purchased this session it prompts the user to purchase the item.

PromiseGamePassOrProductUnlockOrPrompt

GameProductServiceClient:PromiseGamePassOrProductUnlockOrPrompt(
gamePassIdOrKeystring | number,
productIdOrKeystring | number
) → Promise<boolean>

Promises to either check a gamepass or a product to see if it's purchased.

Show raw api
{
    "functions": [
        {
            "name": "Init",
            "desc": "Initializes the service. Should be done via [ServiceBag]",
            "params": [
                {
                    "name": "serviceBag",
                    "desc": "",
                    "lua_type": "ServiceBag"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 31,
                "path": "src/gameproductservice/src/Client/GameProductServiceClient.lua"
            }
        },
        {
            "name": "Start",
            "desc": "Starts the service. Should be done via [ServiceBag]",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 56,
                "path": "src/gameproductservice/src/Client/GameProductServiceClient.lua"
            }
        },
        {
            "name": "ObservePlayerAssetPurchased",
            "desc": "Fires when the specified player purchases an asset",
            "params": [
                {
                    "name": "assetType",
                    "desc": "",
                    "lua_type": "GameConfigAssetType"
                },
                {
                    "name": "idOrKey",
                    "desc": "",
                    "lua_type": "string | number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 80,
                "path": "src/gameproductservice/src/Client/GameProductServiceClient.lua"
            }
        },
        {
            "name": "ObserveAssetPurchased",
            "desc": "Fires when any player purchases an asset",
            "params": [
                {
                    "name": "assetType",
                    "desc": "",
                    "lua_type": "GameConfigAssetType"
                },
                {
                    "name": "idOrKey",
                    "desc": "",
                    "lua_type": "string | number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<Player>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 94,
                "path": "src/gameproductservice/src/Client/GameProductServiceClient.lua"
            }
        },
        {
            "name": "HasPlayerPurchasedThisSession",
            "desc": "Returns true if item has been purchased this session",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                },
                {
                    "name": "assetType",
                    "desc": "",
                    "lua_type": "GameConfigAssetType"
                },
                {
                    "name": "idOrKey",
                    "desc": "",
                    "lua_type": "string | number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 109,
                "path": "src/gameproductservice/src/Client/GameProductServiceClient.lua"
            }
        },
        {
            "name": "PromisePromptPurchase",
            "desc": "Prompts the user to purchase the asset, and returns true if purchased",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                },
                {
                    "name": "assetType",
                    "desc": "",
                    "lua_type": "GameConfigAssetType"
                },
                {
                    "name": "idOrKey",
                    "desc": "",
                    "lua_type": "string | number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<boolean>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 125,
                "path": "src/gameproductservice/src/Client/GameProductServiceClient.lua"
            }
        },
        {
            "name": "PromisePlayerOwnership",
            "desc": "Returns true if item has been purchased this session",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                },
                {
                    "name": "assetType",
                    "desc": "",
                    "lua_type": "GameConfigAssetType"
                },
                {
                    "name": "idOrKey",
                    "desc": "",
                    "lua_type": "string | number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<boolean>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 142,
                "path": "src/gameproductservice/src/Client/GameProductServiceClient.lua"
            }
        },
        {
            "name": "ObservePlayerOwnership",
            "desc": "Observes if the player owns this cloud asset or not",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                },
                {
                    "name": "assetType",
                    "desc": "",
                    "lua_type": "GameConfigAssetType"
                },
                {
                    "name": "idOrKey",
                    "desc": "",
                    "lua_type": "string | number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<boolean>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 158,
                "path": "src/gameproductservice/src/Client/GameProductServiceClient.lua"
            }
        },
        {
            "name": "PromisePlayerIsPromptOpen",
            "desc": "Returns true if the prompt is open",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<boolean>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 172,
                "path": "src/gameproductservice/src/Client/GameProductServiceClient.lua"
            }
        },
        {
            "name": "PromisePlayerPromptClosed",
            "desc": "Returns a promise that will resolve when all prompts are closed",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 186,
                "path": "src/gameproductservice/src/Client/GameProductServiceClient.lua"
            }
        },
        {
            "name": "PromisePlayerOwnershipOrPrompt",
            "desc": "Checks if the asset is ownable and if it is, checks player ownership. Otherwise, it checks if the asset\nhas been purchased this session. If the asset has not been purchased this session it prompts the user to\npurchase the item.",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                },
                {
                    "name": "assetType",
                    "desc": "",
                    "lua_type": "GameConfigAssetType"
                },
                {
                    "name": "idOrKey",
                    "desc": "",
                    "lua_type": "string | number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<boolean>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 204,
                "path": "src/gameproductservice/src/Client/GameProductServiceClient.lua"
            }
        },
        {
            "name": "PromiseGamePassOrProductUnlockOrPrompt",
            "desc": "Promises to either check a gamepass or a product to see if it's purchased.",
            "params": [
                {
                    "name": "gamePassIdOrKey",
                    "desc": "",
                    "lua_type": "string | number"
                },
                {
                    "name": "productIdOrKey",
                    "desc": "",
                    "lua_type": "string | number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<boolean>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 219,
                "path": "src/gameproductservice/src/Client/GameProductServiceClient.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "GameProductServiceClient",
    "desc": "This service provides an interface to purchase produces, assets, and other\nmarketplace items. This listens to events, handles requests between server and\nclient, and takes in both assetKeys from GameConfigService, as well as\nassetIds.\n\nSee [GameProductService] for the server equivalent. The API surface should be\neffectively the same between the two.",
    "realm": [
        "Client"
    ],
    "source": {
        "line": 13,
        "path": "src/gameproductservice/src/Client/GameProductServiceClient.lua"
    }
}