Question about Switch
#3

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:
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!}
}
Cheers!
Reply


Messages In This Thread
Question about Switch - by CoDeZ - 24.07.2012, 17:56
Re: Question about Switch - by next-studio|TheKiller - 24.07.2012, 18:00
Re: Question about Switch - by Jeffry - 24.07.2012, 18:02
Re: Question about Switch - by CoDeZ - 24.07.2012, 18:18
Re: Question about Switch - by Vince - 24.07.2012, 18:22
Re: Question about Switch - by leonardo1434 - 24.07.2012, 18:27
Re: Question about Switch - by CoDeZ - 24.07.2012, 19:22
Re: Question about Switch - by CoDeZ - 24.07.2012, 20:51
Re: Question about Switch - by [KHK]Khalid - 24.07.2012, 20:58
Re: Question about Switch - by Jeffry - 25.07.2012, 09:42

Forum Jump:


Users browsing this thread: 1 Guest(s)