WhoAmI Service
1. Introduction
WhoAmIService
provides information about the player via a REST API. Developers can use it to retrieve various player attributes or request custom data from the backend.
2. What does the package do?
- Makes a GET request to the endpoint:
https://whoami.lionstudios.cc/v1/
- Fetches player-related data based on the provided key.
- Returns structured data to help developers customize player experiences.
3. Usage
WhoAmIService
is a static class within the Lion SDK, providing predefined helper functions to simplify fetching player data.
Implementation
The following helper functions are available, allowing developers to easily access common player attributes without dealing with API requests directly.
Function Name | Description | Return Value |
---|---|---|
IsPayer | Checks if the player has made any previous purchases in this or any other LionStudio game. | Boolean |
Example
public async void Test()
{
bool isPlayerIsPayer = await WhoAmIService.IsPayer();
}
4. Advanced Usage
If developers need data not included in the predefined functions, a generic method is available. This method allows retrieving custom values without requiring LionSDK update.
Implementation
Generic method: The GetValue<T>()
function enables fetching custom data based on a specified key. The returned value can be of any primitive data type or a custom class.
Code signature
//An async function WhoAmIService.GetValue<T>("key");
Full Example:
public async void Test() { bool isPlayerIsPayer = await WhoAmIService.GetValue<bool>("is_payer"); }
💡 |
|