PDA

View Full Version : switch


Sarra
16/08/2014, 04:39 PM
Hi!
GetPlayerHealth(playerid, PlayerHealth);
switch(VehicleHealthAfter[playerid]-VehicleHealthBefore[playerid])
{
case 5..20:
{

SetPlayerHealth(playerid, PlayerHealth-10);
}
case 20..50:
{

SetPlayerHealth(playerid, PlayerHealth-20);
}
case 50..100:
{

SetPlayerHealth(playerid, PlayerHealth-40);
}
}
This doesn't work since I repeated the "20" and the "50" so.. I want something like that

if ((VehicleHealthAfter[playerid]-VehicleHealthBefore[playerid]) >=5 && (VehicleHealthAfter[playerid]-VehicleHealthBefore[playerid]) <20)

SetPlayerHealth(playerid, PlayerHealth-10);

else if ((VehicleHealthAfter[playerid]-VehicleHealthBefore[playerid]) >=20 && (VehicleHealthAfter[playerid]-VehicleHealthBefore[playerid]) <50)

SetPlayerHealth(playerid, PlayerHealth-25);
// else if ....

If I can use something like "else if" in the "switch" it'll be okay