SA-MP Forums Archive
Engine Command Issue - Quick Question - 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: Engine Command Issue - Quick Question (/showthread.php?tid=319396)



Engine Command Issue - Quick Question - Abreezy - 18.02.2012

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!


Re: Engine Command Issue - Quick Question - Vince - 18.02.2012

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)



Re: Engine Command Issue - Quick Question - Abreezy - 19.02.2012

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.