25.06.2011, 17:03
Here with floatround
Another note:
Using "85..89" doesnt speed up the code, its the same as "85, 86, 87, 89" (4 checks)
if(85 <= health < 90) would be better in that case
PS: Cant prove that at the moment, but I am quite sure that this is correct
pawn Код:
//
new
i = 1,
Float: Health;
for( ; i != 19; ++i) {
TextDrawHideForPlayer(playerid, HealthBar[i]);
}
GetPlayerHealth(playerid, Health);
switch(floatround(((Health / 5.0), floatround_floor)) {
case 18: { //18 * 5 => 90 - 94
TextDrawShowForPlayer(playerid,HealthBar[1]);
TextDrawShowForPlayer(playerid,HealthBar[2]);
}
//...
case 5: { //5 * 5 => 25 - 29
TextDrawShowForPlayer(playerid,HealthBar[13]);
TextDrawShowForPlayer(playerid,HealthBar[18]);
}
case 0..4: {} // 0 - 24
default: { //everything which isnt between 0 - 94
TextDrawShowForPlayer(playerid,HealthBar[1]);
TextDrawShowForPlayer(playerid,HealthBar[2]);
}
}
Using "85..89" doesnt speed up the code, its the same as "85, 86, 87, 89" (4 checks)
if(85 <= health < 90) would be better in that case
PS: Cant prove that at the moment, but I am quite sure that this is correct