Vehicle health problem
#1

I'm trying to test my engine command and it doesnt matter that my vehicle health is full (1000)

The engine still doesnt start :/

pawn Код:
public TurnOnEngine(playerid, vehicle2)
{

    new Float:health;
    new vehicleid = GetPlayerVehicleID(playerid);
    new vehhealth = GetVehicleHealth(vehicleid, health);
    if(vehhealth >= 0 && vehhealth <= 250)
    {
        new sendername[MAX_PLAYER_NAME];
        new string[256];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "Engine didn't start ((%s)) ", sendername);
        ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        return 1;
    }
    else
    {
        if(Vehicle3[vehicle2][Engine] == 0)
        {
           // GameTextForPlayer(playerid,"~W~Engine turned ~g~On",3000,1);
            //TogglePlayerControllable(playerid, true);
            new sendername[MAX_PLAYER_NAME];
            new string[256];
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "Engine started ((%s)) ", sendername);
            ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);

            Vehicle3[vehicle2][Engine] = 1;
            SetVehicleParamsEx(GetPlayerVehicleID(playerid),1,lights,alarm,doors,bonnet,boot,objective);
        }
    }
    return true;
}
Reply
#2

shouldn't you make if(vehhealth >= 0 && vehhealth <= 250) dont start else start
like
pawn Код:
if(vehhealth >= 0 && vehhealth <= 250)
{
SetVehicleParamsEx(engineoff);
}
else
{
SetVehicleParamsEx(engineon);
}
Reply
#3

The top bit for
pawn Код:
if(vehhealth >= 0 && vehhealth <= 250)
is for not starting the engine and bottom
pawn Код:
else
for startting it, but it doesnt start with health above 250
Reply
#4

Код:
public TurnOnEngine(playerid, vehicle2)
{

    new Float:health;
    new vehicleid = GetPlayerVehicleID(playerid);
    new vehhealth = GetVehicleHealth(vehicleid, health);
    if(health >= 0 && health <= 250 && Vehicle3[vehicle2][Engine] == 0)
    {
        new sendername[MAX_PLAYER_NAME];
        new string[256];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "Engine didn't start ((%s)) ", sendername);
        ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        return 1;
    }
    else // changed this..
    {
           // GameTextForPlayer(playerid,"~W~Engine turned ~g~On",3000,1);
            //TogglePlayerControllable(playerid, true);
            new sendername[MAX_PLAYER_NAME];
            new string[256];
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "Engine started ((%s)) ", sendername);
            ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);

            Vehicle3[vehicle2][Engine] = 1;
            SetVehicleParamsEx(GetPlayerVehicleID(playerid),1,lights,alarm,doors,bonnet,boot,objective);
    }
    return true;
}
Try that...
Reply
#5

No, you dont get me, is not that the engine doesnt start as in SetVehicleParamsEx... Basically it goes through the first option and message comes up that it didnt start the engine even that the car health is more than 250 get it?
Reply
#6

GetVehicleHealth doesn't return any value. It stores the health in a variable passed by reference.
In your case, that variable is health, and not vehhealth.
Reply
#7

Exactly, so the parameter "health" that you chose to use is where the vehicle health is stored.
Reply
#8

I edited my other post.. take a look
Reply
#9

Quote:
Originally Posted by Joshb93
Посмотреть сообщение
I edited my other post.. take a look
You silly boy, the vehhealth parameter is 0.0 because GetVehicleHealth does not return the health, it passes it to the second parameter.
Reply
#10

Quote:
Originally Posted by Austin
Посмотреть сообщение
You silly boy, the vehhealth parameter is 0.0 because GetVehicleHealth does not return the health, it passes it to the second parameter.
You silly boy.. look at muh post.. ^.^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)