get_player_stat - ryzom/ryzomcore GitHub Wiki


title: Get Player Stat description: published: true date: 2023-03-12T22:41:13.398Z tags: editor: markdown dateCreated: 2023-03-12T22:40:54.207Z

getPlayerStat

The getPlayerStat native AI script function retrieves a specified statistic for a given player.

Syntax

(result: s)getPlayerStat(playerEidAsString: s, statName: s)

Arguments

  • playerEidAsString (string): The entity ID of the player as a string.
  • statName (string): The name of the property to retrieve. Valid values are "HP", "MaxHp", and "RatioHp".

Return value

  • result (string): The value of the specified statistic for the given player.

Notes

  • The player must be in the same AI instance (continent) as the calling entity.
  • If the input string is empty or the player is not in the same AI instance, the function returns zero and displays a warning message in the log.
  • The argument is case sensitive.

Example

($playerEid)getCurrentPlayerEid();
print($playerEid); //log (0x00001fbd50:00:00:81)
($maxHp)getPlayerStat($playerEid, "MaxHp");

This example code retrieves the maximum hit points for the current player and stores the result in the variable maxHp.

⚠️ **GitHub.com Fallback** ⚠️