Engine CMD is not working... (you'd think it would be simple)
#1

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.
Reply
#2

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

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. :/
Reply
#4

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;
}
Reply
#5

Figured it out! RESOLVED
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)