24.07.2012, 18:02
Switch works with integers only, not with Floats.
https://sampwiki.blast.hk/wiki/Control_Structures#switch_2
You can convert your Float into an integer, and then use switch:
Cheers!
https://sampwiki.blast.hk/wiki/Control_Structures#switch_2
You can convert your Float into an integer, and then use switch:
pawn Код:
new Float:teehee;
GetPlayerHealth(playerid,teehee);
new tmp[5];
format(tmp, sizeof(tmp), "%0.0f", teehee); //Not sure if 0.0f works, just try it. ^^
new health = strval(tmp);
switch(health)
{
case 80..100: {//Stuff here}
case 60..79: {//Stuff here}
case 40..59: {//Stuff here}
case 20..39: {//Stuff here}
case 0..19: {//Stuff here}
default: {//Either smaller 0 or bigger 100, O.o Hax!}
}