Engine Command Issue - Quick Question
#1

Alright I made this command:

pawn Код:
CMD:engine(playerid, params[])
{
    if(IsPlayerInAnyVehicle(playerid))

    {
        new car = GetPlayerVehicleID(playerid);
        new string[128];
        GetVehicleParamsEx(car, engine, lights, alarm, doors, bonnet, boot, objective);
       
        if(engine == 0)
        {
            SetTimerEx("Engine", 5000, false, "d", playerid);
            format(string, sizeof(string), "* %s tries to turn on the vehicle engine.. *", pName(playerid));
            SendLocalMessage(playerid, string, 10.0, COLOR_PINK, COLOR_PINK);
        }
        else
        {
            SetVehicleParamsEx(car,0,lights,alarm,doors,bonnet,boot,objective);
            format(string, sizeof(string), "* %s turns the key on the ignition, turning off the vehicle.. *", pName(playerid));
            SendLocalMessage(playerid, string, 10.0, COLOR_PINK, COLOR_PINK);
        }
    }
    return 1;
}

It should either turn on or off an engine when your in the vehicle, but the issue is, when I spawn a car and go in it and do /engine it always say "turning off the vehicle" part. But the vehicles spawn as off already, so how could I fix this issue? Thank you very much in advance!
Reply
#2

I think when a vehicle spawns all params are set as "unset" which is defined as -1, not 0. So try changing
pawn Код:
if(engine == 0)
to
pawn Код:
if(engine != 1)
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
I think when a vehicle spawns all params are set as "unset" which is defined as -1, not 0. So try changing
pawn Код:
if(engine == 0)
to
pawn Код:
if(engine != 1)
Worked, Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)