Battery
#9

This is more optimized and has a better repartition I think:
pawn Код:
if ( TVar[ playerid ][ tBattery ] > 80 ) {   format( Battery, sizeof( Battery ),"|||||");}
else if ( TVar[ playerid ][ tBattery ] > 60 )  {   format( Battery, sizeof( Battery ),"||||");}
else if ( TVar[ playerid ][ tBattery ] > 40 )  {   format( Battery, sizeof( Battery ),"|||" );}
else if ( TVar[ playerid ][ tBattery ] > 20 )  {   format( Battery, sizeof( Battery ),"||" );}
else {   format( Battery, sizeof( Battery ),"|" );}
There's also another way to do:
pawn Код:
format( Battery, sizeof( Battery ),"|||||");
Battery[TVar[playerid][tBattery]/20]='\0';
I need this second solution to be confirmed though: I have no script to test it. I'll explain the principle: '\0' is the "end of string" character, which is used to determine where is the end of the string. When a script reads that character, it assumes that the previous character was the last one.
Reply


Messages In This Thread
Battery - by No Fear - 29.12.2011, 08:26
Re: Battery - by Seven_of_Nine - 29.12.2011, 08:30
Re: Battery - by No Fear - 29.12.2011, 08:32
Re: Battery - by Seven_of_Nine - 29.12.2011, 08:34
Re: Battery - by No Fear - 29.12.2011, 08:35
Re: Battery - by [ABK]Antonio - 29.12.2011, 08:40
Re: Battery - by Seven_of_Nine - 29.12.2011, 08:42
Re: Battery - by No Fear - 29.12.2011, 08:49
Re : Battery - by decondelite - 29.12.2011, 09:26

Forum Jump:


Users browsing this thread: 1 Guest(s)