SA-MP Forums Archive
Engine CMD is not working... (you'd think it would be simple) - 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 CMD is not working... (you'd think it would be simple) (/showthread.php?tid=560602)



Engine CMD is not working... (you'd think it would be simple) - Aerotactics - 29.01.2015

pawn Код:
CMD:en(playerid, params[])
{
    new vehicleid = GetPlayerVehicleID(playerid);
    new engine,lights,alarm,doors,bonnet,boot,objective;
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(engine == 0)
        {
            SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective);
            new str[128];
            format(str, sizeof(str), "* %s twists the key in the ignition, turning the engine [ON]. *", GetName(playerid));
            SendRangeMessage(playerid, COLOR_DO, str, 15);
            return 1;
        }
        else if(engine == 1)
        {
            SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
            new str[128];
            format(str, sizeof(str), "* %s twists the key in the ignition, turning the engine [OFF]. *", GetName(playerid));
            SendRangeMessage(playerid, COLOR_DO, str, 15);
            return 1;
        }
    }
    return 1;
}
RESOLVED: there is a third parameter for vehicles other than off and on, and that is unspecified, or -1.


Re: Engine CMD is not working... (you'd think it would be simple) - Rabea - 29.01.2015

What is the problem.
i mean what happens when you type /en?


Re: Engine CMD is not working... (you'd think it would be simple) - Aerotactics - 29.01.2015

Quote:
Originally Posted by Rabea
Посмотреть сообщение
What is the problem.
i mean what happens when you type /en?
Nothing happens, literally. No messages pop up, no engines turn on. :/


Re: Engine CMD is not working... (you'd think it would be simple) - KayJ - 29.01.2015

EDIT: This may help you
Quote:
Originally Posted by PowerPC603
Посмотреть сообщение
pawn Код:
COMMAND:engine(playerid, params[])
{
    new engine, lights, alarm, doors, bonnet, boot, objective;
    new vid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);

    if(engine == 1)
    {
        SetVehicleParamsEx(vid, 0, lights, alarm, doors, bonnet, boot, objective);
        SCM(playerid, COLOR_GREEN, "You have turned off your vehicles engine.");
    }
    else if(engine == 0)
    {
        SetVehicleParamsEx(vid, 1, lights, alarm, doors, bonnet, boot, objective);
        SCM(playerid, COLOR_GREEN, "You have turned on your vehicles engine.");
    }
    return 1;
}
Your variable "engine" was always 0 when you entered the command, as you didn't get the engine-status first by using GetVehicleParamsEx.
Quote:
Originally Posted by LiamM
Посмотреть сообщение
I have allready tried this and when I re tried it, it returned nothing for the vehicles. I could not turn on any vehicles engine, therefore all vehicles were un-moveable. I have these definitions to, I will show you my entire cmd + defines

pawn Код:
#define VEHICLE_PARAMS_UNSET    -1
#define VEHICLE_PARAMS_OFF  0
#define VEHICLE_PARAMS_ON   1


COMMAND:engine(playerid, params[])
{
    new engine, lights, alarm, doors, bonnet, boot, objective;
    new vid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);

    if(engine == 1)
    {
        SetVehicleParamsEx(vid, 0, lights, alarm, doors, bonnet, boot, objective);
        SCM(playerid, COLOR_GREEN, "You have turned off your vehicles engine.");
    }
    else if(engine == 0)
    {
        SetVehicleParamsEx(vid, 1, lights, alarm, doors, bonnet, boot, objective);
        SCM(playerid, COLOR_GREEN, "You have turned on your vehicles engine.");
    }
    return 1;
}



Re: Engine CMD is not working... (you'd think it would be simple) - Aerotactics - 29.01.2015

Figured it out! RESOLVED