HealthBar
#4

Here with floatround

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]);
        }
    }
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
Reply


Messages In This Thread
HealthBar - by LZLo - 25.06.2011, 15:46
AW: HealthBar - by Nero_3D - 25.06.2011, 16:18
Re: HealthBar - by LZLo - 25.06.2011, 16:23
AW: HealthBar - by Nero_3D - 25.06.2011, 17:03
Re: HealthBar - by LZLo - 25.06.2011, 17:07

Forum Jump:


Users browsing this thread: 1 Guest(s)