Skip to main content

GameProductService

This item only works when running on the server. Server

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 GameProductServiceClient for the client equivalent. The API surface should be effectively the same between the two.

Functions

Init

GameProductService:Init(serviceBagServiceBag) → ()

Initializes the service. Should be done via ServiceBag

ObservePlayerAssetPurchased

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

Fires when the specified player purchases an asset

ObserveAssetPurchased

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

Fires when any player purchases an asset

HasPlayerPurchasedThisSession

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

Returns true if item has been purchased this session

PromisePlayerIsPromptOpen

GameProductService:PromisePlayerIsPromptOpen(playerPlayer) → Promise<boolean>

Returns true if the prompt is open

PromisePlayerPromptClosed

GameProductService:PromisePlayerPromptClosed(playerPlayer) → Promise

Returns a promise that will resolve when all prompts are closed

PromisePlayerPromptPurchase

GameProductService:PromisePlayerPromptPurchase(
playerPlayer,
assetTypeGameConfigAssetType,
idOrKeystring | number
) → boolean

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

PromisePlayerOwnership

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

Returns true if item has been purchased this session

PromisePlayerOwnershipOrPrompt

GameProductService: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.

ObservePlayerOwnership

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

Observes if the player owns this cloud asset or not

Destroy

GameProductService:Destroy() → ()

Cleans up the game product service

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": 26,
                "path": "src/gameproductservice/src/Server/GameProductService.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": 59,
                "path": "src/gameproductservice/src/Server/GameProductService.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": 73,
                "path": "src/gameproductservice/src/Server/GameProductService.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": 88,
                "path": "src/gameproductservice/src/Server/GameProductService.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": 102,
                "path": "src/gameproductservice/src/Server/GameProductService.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": 115,
                "path": "src/gameproductservice/src/Server/GameProductService.lua"
            }
        },
        {
            "name": "PromisePlayerPromptPurchase",
            "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": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 130,
                "path": "src/gameproductservice/src/Server/GameProductService.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": 146,
                "path": "src/gameproductservice/src/Server/GameProductService.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": 164,
                "path": "src/gameproductservice/src/Server/GameProductService.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": 180,
                "path": "src/gameproductservice/src/Server/GameProductService.lua"
            }
        },
        {
            "name": "Destroy",
            "desc": "Cleans up the game product service",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 191,
                "path": "src/gameproductservice/src/Server/GameProductService.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "GameProductService",
    "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 [GameProductServiceClient] for the client equivalent. The API surface should be\neffectively the same between the two.",
    "realm": [
        "Server"
    ],
    "source": {
        "line": 13,
        "path": "src/gameproductservice/src/Server/GameProductService.lua"
    }
}