29.12.2011, 09:26
This is more optimized and has a better repartition I think:
There's also another way to do:
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.
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 ),"|" );}
pawn Код:
format( Battery, sizeof( Battery ),"|||||");
Battery[TVar[playerid][tBattery]/20]='\0';