SA-MP Forums Archive
[Ajuda] Criar Progress Bar de Vida - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Criar Progress Bar de Vida (/showthread.php?tid=649828)



Criar Progress Bar de Vida - Powered - 15.02.2018

Eae galera, estou com um problema para criar uma progress bar de vida, eu tenho a progress pronta porйm nгo sei como quando levar um tiro, sofrer uma queda ou levar algum dano a barra diminuir, alguem ajuda?


Re: Criar Progress Bar de Vida - GuiKommander - 15.02.2018

Teria que usar essa call Back acho eu.
PHP код:
http://wiki.sa-mp.com/wiki/OnPlayerTakeDamage 



Re: Criar Progress Bar de Vida - Tassi - 15.02.2018

Seta um timer bem baixo ao player spawnar, e na callback do timer coloca a funзгo para setar o valor da progress igual a vida do player. Pelo menos й assim que EU faзo.


Re: Criar Progress Bar de Vida - Powered - 15.02.2018

Quote:
Originally Posted by Tassi
Посмотреть сообщение
Seta um timer bem baixo ao player spawnar, e na callback do timer coloca a funзгo para setar o valor da progress igual a vida do player. Pelo menos й assim que EU faзo.
Tem um exemplo?


Re: Criar Progress Bar de Vida - Tassi - 15.02.2018

Quote:
Originally Posted by Powered
Посмотреть сообщение
Tem um exemplo?
Claro. Vк se funciona.

PHP код:

public OnPlayerSpawn(playerid)
{
    
SetTimer("MostrarVida"10001);
    return 
1;
}
forward MostrarVida(playerid);
public 
MostrarVida(playerid)
{
    new 
Float:VidaJogador;
    
GetPlayerHealth(playerid,VidaJogador);
    
SetProgressBarValue(NOMEPROGRESSVidaJogador);
    
UpdateProgressBar(NOMEPROGRESSplayerid);
    return 
1;




Re: Criar Progress Bar de Vida - Lovejoy - 16.02.2018

Quote:
Originally Posted by Tassi
Посмотреть сообщение
Seta um timer bem baixo ao player spawnar, e na callback do timer coloca a funзгo para setar o valor da progress igual a vida do player. Pelo menos й assim que EU faзo.
Alйm de nгo usar timer, o OnPlayerUpdate й bem mais otimizado e preciso


Re: Criar Progress Bar de Vida - Tassi - 16.02.2018

Quote:
Originally Posted by Lovejoy
Посмотреть сообщение
Alйm de nгo usar timer, o OnPlayerUpdate й bem mais otimizado e preciso
Nгo havia pensado nisso.


Re: Criar Progress Bar de Vida - GuilhermeW - 16.02.2018

Quote:
Originally Posted by Lovejoy
Посмотреть сообщение
Alйm de nгo usar timer, o OnPlayerUpdate й bem mais otimizado e preciso
Realmente vocк estб correto, porйm й bom tomar cuidado com o que coloca nessa callback pois tem que se lembrar do seguinte detalhe:

Код:
This callback is called, on average, 30 times per second, per player; only use it when you know what it's meant for (or more importantly what it's NOT meant for).
Quote:
Originally Posted by Vince
Посмотреть сообщение
You should only use OnPlayerUpdate to create custom callbacks as demonstrated on the wiki page (OnPlayerHealthChange, OnPlayerArmourChange, OnPlayerWeaponChange, ...).

The function is not intended to fulfill the role of a general purpose timer. Things like speedometers should not be placed in OnPlayerUpdate; I would reckon that the minimum update interval for speedometers is around 300 milliseconds, (about the time it takes to blink). OnPlayerUpdate is called on average every 30 milliseconds, which is way faster than strictly necessary.



Re: Criar Progress Bar de Vida - Lovejoy - 16.02.2018

Quote:
Originally Posted by Tassi
Посмотреть сообщение
Claro. Vк se funciona.

PHP код:

public OnPlayerSpawn(playerid)
{
    
SetTimer("MostrarVida"10001);
    return 
1;
}
forward MostrarVida(playerid);
public 
MostrarVida(playerid)
{
    new 
Float:VidaJogador;
    
GetPlayerHealth(playerid,VidaJogador);
    
SetProgressBarValue(NOMEPROGRESSVidaJogador);
    
UpdateProgressBar(NOMEPROGRESSplayerid);
    return 
1;

Vale notar tambйm que vocк usou (SetTimer) esse timer й global, e nгo aconteceria nada com ele no servidor, vocк teria que usar o timer local (SetTimerEx) que te permite especificar a qual id de player/vehicles e outras coisas que a funзгo seria aplicada


Re: Criar Progress Bar de Vida - victorara - 17.02.2018

Resolvido mano?