Hi. I am making a plugin that allow player with the o flag can respawn themselves and restore the boss with the damage they dealt. But the boss will become 0 after 1 use respawn. Can anyone would like to help me? I am bad at coding.
Code:
public Action Command_spawn (int client, int args)
{
new Selfhealth = FF2_GetBossHealth();
new Selfmaxhealth = FF2_GetBossMaxHealth();
//new Selflive = FF2_GetBossLives();
//new Selfmaxlive = FF2_GetBossMaxLives();
new playerdamage = FF2_GetClientDamage(client);
if (IsPlayerAlive(client))
{
CPrintToChat(client,"{white}[{purple}FF2{white}]You are still alive~",client);
return Plugin_Handled;
}
if (respawn[client] == 1)
{
CPrintToChat(client,"{white}[{purple}FF2{white}]You have already used your respawn chance.",client);
return Plugin_Handled;
}
TF2_RespawnPlayer(client);
Selfhealth = RoundToCeil(Selfhealth + playerdamage);
if(Selfhealth > Selfmaxhealth)
{
Selfhealth = Selfmaxhealth;
}
FF2_SetBossHealth(0,Selfhealth);
//FF2_SetBossLives(bossindex,Selflive);
CPrintToChat(client,"{white}[{purple}FF2{white}]You have respawned~",client);
CPrintToChatAll("{white}[{purple}FF2{white}]%N has respawn and restore boss with %d HP!", client, playerdamage);
respawn[client] = 1;
return Plugin_Handled;
}
Another thing is if the boss has 2 or more lives their health will be set to 0 when one use the respawn.