SA-MP Forums Archive
health bar - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: health bar (/showthread.php?tid=664036)



health bar - Volumen - 17.02.2019

I have a personalized health bar, the question is: What callback should I use to update the new bar? 'OnPlayerUpdate', 'OnPlayerTakeDamage' or 'OnPlayerGiveDmage'?


Re: health bar - Kasichok - 17.02.2019

OnPlayerTakeDamage


Re: health bar - Volumen - 17.02.2019

Quote:
Originally Posted by Kasichok
Посмотреть сообщение
OnPlayerTakeDamage
When a player falls from a height and is injured or explodes with the '/ burn' command, is the callback also called?


Re: health bar - HNIC - 17.02.2019

Quote:
Originally Posted by Volumen
Посмотреть сообщение
When a player falls from a height and is injured or explodes with the '/ burn' command, is the callback also called?
Yes, it is.


Re: health bar - Volumen - 17.02.2019

By the way, should you set some variable on the server side to store the health of each player, and avoid the cheaters?

Something like this:

PHP код:
//OnPlayerConnect
Player_Info[playerid][player_Health] = 100.0;
SetPlayerHealth(playeridPlayer_Info[playerid][player_Health]);
//OnPlayerTakeDamage
Player_Info[playerid][player_Health] -= amount;
if(
Player_Info[playerid][player_Health] <= 0.0)
{
SetPlayerHealth(playerid0.0);
}
//Command /kill
CMD:kill(playeridparams[])
{
        
Player_Info[playerid][player_Health] = 0.0;
    
SetPlayerHealth(playeridPlayer_Info[playerid][player_Health]);
    return 
1;
}
//Command /health
CMD:health(playeridparams[])
{
    if(
sscanf(params"df"params[0], params[1])) return SendClientMessage(playerid,-1"/health <playerid> <health>");
    
Player_Info[params[0]][player_Health] = params[1];
    
SetPlayerHealth(params[0], params[1]);
    return 
1;