Skip to content

HealthBars

KissLick edited this page May 27, 2016 · 7 revisions

TeamGames provides simple API for adding HealthBars to players. Each player can only have one HealthBar at the time and if there is some health change that TG core can't recognize, you have to update the HealthBar via TG_UpdatePlayerHealthBar.

So, we have three different natives for HealthBars.

Example

public TG_OnGameStart(const String:id[], TG_GameType:gameType, client, const String:gameSettings[], Handle:dataPack)
{
	if (!StrEqual(id, GAME_ID))
		return;

	for (new i = 1; i <= MaxClients; i++) {
		if (!TG_IsPlayerRedOrBlue(i))
			continue;

		SetEntityHealth(i, 500);

		// Add HealthBar and adjust it to 500HP
		TG_AttachPlayerHealthBar(i, 500);
	}
}