18.02.2017, 21:44
The percentage calculation is just maths.
When implementing this in pawn, beware of integer division, so use floats.
Implementation method:
Код:
% = 100 - (currentValue / maxValue * 100) //Say maxValue is 60 //At the start: 0% = 100 - (60 / 60 * 100) //At the middle: 50% = 100 - (30 / 60 * 100) //At the end: 100% = 100 - (0/ 60 * 100)
Implementation method:
- Before the start of the timer, set maxValue.
- Before the start of the timer, set currentValue to maxValue.
- With every tick of the timer, decrease currentValue and update the string if needed.