[HELP] Engine
#1

I make a sistem engine but is not work, why?

pawn Код:
if (newkeys & KEY_NO)
    {
        if(GetPlayerState(playerid) == 2)
        {
            new vehicle = GetPlayerVehicleID(playerid); //This part here is defining the vehicle ID that the player is currently in.
            if(Engine[vehicle] == 0) //This is checking if the engine of the vehicle, is turned off or not.
            {
                new engine, lights, alarm, doors, bonnet, boot, objective; //This is defining the vehicles current items.
                GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);//This is checking the vehicle's engine/lights/alarm/doors/bonnet/boot/objective status.
                Engine[vehicle] = 1; //This is setting the global variable that you created at the beginning.
                SetVehicleParamsEx(vehicle, 1, lights, alarm, doors, bonnet, boot, 0); //This is setting the vehicles engine to be on.
                GameTextForPlayer(playerid, "~g~ENGINE ON...", 5000, 2);
            }
        }
        else return SendClientMessage(playerid, COLOR_GREY, "* Engine already running*");
    }
    if (newkeys & KEY_NO)
    {
        if(GetPlayerState(playerid) == 2)
        {
            new vehicle = GetPlayerVehicleID(playerid); //This part here is defining the vehicle ID that the player is currently in.
            if(Engine[vehicle] == 1) //This is checking if the engine of the vehicle, is turned off or not.
            {
                new engine, lights, alarm, doors, bonnet, boot, objective; //This is defining the vehicles current items.
                GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);//This is checking the vehicle's engine/lights/alarm/doors/bonnet/boot/objective status.
                Engine[vehicle] = 0; //This is setting the global variable that you created at the beginning.
                SetVehicleParamsEx(vehicle, 0, lights, alarm, doors, bonnet, boot, 0); //This is setting the vehicles engine to be on.
                GameTextForPlayer(playerid, "~r~ENGINE OFF...", 5000, 2);
            }
        }
    }
Reply
#2

Sorry.. try to remove:

pawn Код:
else return //... rest
Reply
#3

Your code will set engine to 1 if the key is KEY_NO and the player is driver and then the second part will be called so it will disable the engine right away.

pawn Код:
if (newkeys & KEY_NO)
{
    if(GetPlayerState(playerid) == 2)
    {
        new vehicle = GetPlayerVehicleID(playerid); //This part here is defining the vehicle ID that the player is currently in.
        new engine, lights, alarm, doors, bonnet, boot, objective; //This is defining the vehicles current items.
        GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);//This is checking the vehicle's engine/lights/alarm/doors/bonnet/boot/objective status.
        if(Engine[vehicle] == 0) //This is checking if the engine of the vehicle, is turned off or not.
        {
            Engine[vehicle] = 1; //This is setting the global variable that you created at the beginning.
            SetVehicleParamsEx(vehicle, 1, lights, alarm, doors, bonnet, boot, 0); //This is setting the vehicles engine to be on.
            GameTextForPlayer(playerid, "~g~ENGINE ON...", 5000, 2);
        }
        else
        {
            Engine[vehicle] = 0; //This is setting the global variable that you created at the beginning.
            SetVehicleParamsEx(vehicle, 0, lights, alarm, doors, bonnet, boot, 0); //This is setting the vehicles engine to be on.
            GameTextForPlayer(playerid, "~r~ENGINE OFF...", 5000, 2);
        }
    }
}
Reply
#4

It's work's. SOLVED.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)