/engine, and /lights problem
#1

Hello, there. I created /engine and /lights commands earlier today, and it worked great, but then something happened, I don't know what but something did happen.. So, please see if you guys can see what's wrong here. Compiles fine
Okay, the problem is: When I enter the vehicle, it turns the engine and lights on, and when I exit it, they both turn off..
Thanks in advance.

new
pawn Код:
new Engine[MAX_VEHICLES];
new Lights[MAX_VEHICLES];
OnVehicleSpawn
pawn Код:
public OnVehicleSpawn(vehicleid)
{
        Engine[vehicleid] = 0;
    Lights[vehicleid] = 0;
    return 1;
}
And of course, the commands

pawn Код:
CMD:engine(playerid, params[])
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        if(GetPlayerState(playerid) == 2)
        {
            new vehicle = GetPlayerVehicleID(playerid);
            if(Engine[vehicle] == 0)
            {
                new engine, lights, alarm, doors, bonnet, boot, objective;
                GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
                Engine[vehicle] = 1;
                SetVehicleParamsEx(vehicle, 1, lights, alarm, doors, bonnet, boot, 0);
                SCM(playerid, -1, "Engine"#COL_GREEN" On");
            }else if(Engine[vehicle] == 1)
            {
                new engine, lights, alarm, doors, bonnet, boot, objective;
                GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
                Engine[vehicle] = 0;
                SetVehicleParamsEx(vehicle, 0, lights, alarm, doors, bonnet, boot, 0);
                SCM(playerid, -1, "Engine"#COL_RED" Off");
            }
        }else return SCM(playerid, -1, "You're not the driver of the vehicle.");
    }else return SCM(playerid, -1, "You're not in a vehicle.");
    return 1;
}

pawn Код:
CMD:lights(playerid, params[])
{
    if(GetPlayerState(playerid) == 2)
    {
        new vehicle = GetPlayerVehicleID(playerid);
        if(Lights[vehicle] == 0)
        {
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
            Lights[vehicle] = 1;
            SetVehicleParamsEx(vehicle, engine, 1, alarm, doors, bonnet, boot, 0);
            SCM(playerid, -1, "Lights"#COL_GREEN" On");
        }else if(Lights[vehicle] == 1)
        {
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
            Lights[vehicle] = 0;
            SetVehicleParamsEx(vehicle, engine, 0, alarm, doors, bonnet, boot, 0);
            SCM(playerid, -1, "Lights"#COL_RED" Off");
        }
    }else return SCM(playerid, -1, "You're not the driver of the vehicle");
    return 1;
}
Reply
#2

I don't think you can do anything about that.
Samp automatically makes the lights go off when no player is in the vehicle.
Reply
#3

Not true. I've seen this before. plus, it worked before.
Reply
#4

Ok, then show me your onplayerexitvehicle and onplayerstatechange please.
Reply
#5

OnPlayerExitVehicle
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}
Empty..

OnPlayerStateChange
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new carid;
    new i = 0;
    if(carid == CopCar[i])
    {
    if(PlayerInfo[playerid][pMember] == 1)
    return 1;
    }
    else return RemovePlayerFromVehicle(playerid), SCM(playerid,RED,"You're NOT an Flint County Sheriffs Department Officer!");

    if(carid == FBI[i])
    {
    if(PlayerInfo[playerid][pMember] == 2)
    return 1;
    }
    else return RemovePlayerFromVehicle(playerid), SCM(playerid,RED,"You're NOT in the FBI!");
    if(carid == FCFD[i])
    {
    if(PlayerInfo[playerid][pMember] == 3)
    return 1;
    }
    else return RemovePlayerFromVehicle(playerid), SCM(playerid,RED,"You're NOT an Flint County Fire Department member!");
    return 1;
}
Doubt it's anything wrong with that ;s
Reply
#6

Ok, the I don't know, sorry
Reply
#7

Thanks, anyway Hope there's somebody here that can help me solve this.
Reply
#8

*Fixed by me.
Reply
#9

So what was wrong?
Reply
#10

He forgot to put:

"Engine = 0;" on "OnGameModeInit"
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)