SA-MP Forums Archive
Vehicle health problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Vehicle health problem (/showthread.php?tid=298369)



Vehicle health problem - HondaCBR - 20.11.2011

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;
}



Re: Vehicle health problem - wumpyc - 20.11.2011

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);
}



Re: Vehicle health problem - HondaCBR - 20.11.2011

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


Re: Vehicle health problem - Joshb93 - 20.11.2011

Код:
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...


Re: Vehicle health problem - HondaCBR - 20.11.2011

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?


Re: Vehicle health problem - [NoV]LaZ - 20.11.2011

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.


Re: Vehicle health problem - Austin - 20.11.2011

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


Re: Vehicle health problem - Joshb93 - 20.11.2011

I edited my other post.. take a look


Re: Vehicle health problem - Austin - 20.11.2011

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.


Re: Vehicle health problem - Joshb93 - 20.11.2011

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.. ^.^