07.11.2013, 16:51
Hey, I have little problem with switch random thing..
I want to make if car have more than 500hp there are 100% chances to turn engine on (this is working perfect)
But if car is under 500HP I want to make random thing.. but it's working somehow but the problem is.. time to time this random thing don't even choose the given options "case 1" or "case 2" there isn't any effect / SendClientMessage or anything...
here is the code
What is wrong ?
I want to make if car have more than 500hp there are 100% chances to turn engine on (this is working perfect)
But if car is under 500HP I want to make random thing.. but it's working somehow but the problem is.. time to time this random thing don't even choose the given options "case 1" or "case 2" there isn't any effect / SendClientMessage or anything...
here is the code
pawn Код:
public EngStart(playerid)
{
new Float:vehHP, vehicle = GetPlayerVehicleID(playerid);
GetVehicleHealth(vehicle, vehHP);
if(vehHP >= 500)
{
Eng[playerid] = 1;
SendClientMessage(playerid, COLOR_YELLOW,"Engine is succesfully started");
TogglePlayerControllable(playerid, 1);
}
if(vehHP <= 500)
{
switch(random(3))
{
case 1:
{
Eng[playerid] = 1;
SendClientMessage(playerid, COLOR_YELLOW,"Engine is succesfully started");
TogglePlayerControllable(playerid, 1);
}
case 2:
{
Eng[playerid] = 0;
SendClientMessage(playerid, COLOR_YELLOW,"Engine failed to start, please try again");
TogglePlayerControllable(playerid, 0);
}
}
}
return 1;
}