GetVehicleHealth
#1

I have this code, i think its correct, but even the vehicle being wih full health, why does it still send a message saying
"It's to wrecked... use (/phone)"
Everything works exept that bit of the health, if it's full it still sends a message saying it's to wrecked
pawn Код:
public Start(playerid)
{
    new engine,lights,alarm,doors,bonnet,boot,objective,Float:health,rand;
    if(GetVehicleHealth(GetPlayerVehicleID(playerid),health) < 500)
    {
        SendClientMessage(playerid,white,"*"lred"The vehicle is too wrecked, please call assistance! "lyellow2"(/phone)");
        starting[playerid] = 0;
    }
    rand = random(2);
    if(rand == 0)
    {
        SendClientMessage(playerid,white,"*"lred"Unable to start the vehicle"lwhite"*");
        starting[playerid] = 0;
    }
    if(rand == 1 && Started[GetPlayerVehicleID(playerid)] == 0)
    {
        GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
        SetVehicleParamsEx(GetPlayerVehicleID(playerid),1,lights,alarm,doors,bonnet,boot,objective);
        Started[GetPlayerVehicleID(playerid)] = 1;
        SendClientMessage(playerid,white,"*"lred"Vehicle "lgreen"started"lred"!"lwhite"*");
        starting[playerid] = 0;
    }
    return 1;
}
Reply
#2

Код:
public Start(playerid)
{
    new engine,lights,alarm,doors,bonnet,boot,objective,Float:health,rand;
    GetVehicleHealth(GetPlayerVehicleID(playerid), health);
    if(health < 500)
    {
        SendClientMessage(playerid,white,"*"lred"The vehicle is too wrecked, please call assistance! "lyellow2"(/phone)");
        starting[playerid] = 0;
    }
    rand = random(2);
    if(rand == 0)
    {
        SendClientMessage(playerid,white,"*"lred"Unable to start the vehicle"lwhite"*");
        starting[playerid] = 0;
    }
    if(rand == 1 && Started[GetPlayerVehicleID(playerid)] == 0)
    {
        GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
        SetVehicleParamsEx(GetPlayerVehicleID(playerid),1,lights,alarm,doors,bonnet,boot,objective);
        Started[GetPlayerVehicleID(playerid)] = 1;
        SendClientMessage(playerid,white,"*"lred"Vehicle "lgreen"started"lred"!"lwhite"*");
        starting[playerid] = 0;
    }
    return 1;
}
Try that.

You called function to get vehicle's health in a if() statment. That does nothing, it just stores vehicle's health in a variable. Because function returnes 1 or 0 it's smaller that 500 and then the code in if() statment is called.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)