The getPlayerStat native AI script function retrieves a specified statistic for a given player.
(result: s)getPlayerStat(playerEidAsString: s, statName: s)
- 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".
- result (string): The value of the specified statistic for the given player.
- 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.
($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
.