15.02.2018, 21:24
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?
http://wiki.sa-mp.com/wiki/OnPlayerTakeDamage
public OnPlayerSpawn(playerid)
{
SetTimer("MostrarVida", 1000, 1);
return 1;
}
forward MostrarVida(playerid);
public MostrarVida(playerid)
{
new Float:VidaJogador;
GetPlayerHealth(playerid,VidaJogador);
SetProgressBarValue(NOMEPROGRESS, VidaJogador);
UpdateProgressBar(NOMEPROGRESS, playerid);
return 1;
}
Alйm de nгo usar timer, o OnPlayerUpdate й bem mais otimizado e preciso
|
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).
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. |
Claro. Vк se funciona.
PHP код:
|