/engine command
#1

Alright, I ran and compiled this with no errors, but the minute I go to test it on my server, it doesn't work...

pawn Код:
if(!strcmp(cmdtext, "/engine", true))
    {
        new veh = GetPlayerVehicleID(playerid);
        new engineStatus[MAX_VEHICLES];
        if(engineStatus[veh] = 0)
        {
            new
                engine,
                lights,
                alarm,
                doors,
                bonnet,
                boot,
                objective;
               
            GetVehicleParamsEx(veh, engine,  lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(veh, 1, lights, alarm, doors, bonnet, boot, objective);
            engineStatus[veh] = 1;
        }
        else
        {
            new engine, lights, alarm, doors, bonnet, boot,objective;
            GetVehicleParamsEx(veh, engine,  lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(veh, 0, lights, alarm, doors, bonnet, boot, objective);
            engineStatus[veh] = 0;
        }
        return 1;
    }
Reply
#2

i believe it's because you have a local variable engineStatus, and everytime you write /engine that specific var is 0, so it will always execute the first condition. am try making it global variable.
Reply
#3

Try this, not tested though.
pawn Код:
if(!strcmp(cmdtext, "/engine", true)) {
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You are not in any vehicle.")
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "You need to be the driver.");
    new veh = GetPlayerVehicleID(playerid);
    new engine, lights, alarm, doors, bonnet, boot, objective;
    GetVehicleParamsEx(veh, engine, lights, alarm, doors, bonnet, boot, objective);
    if(engine) SetVehicleParamsEx(veh, 0, lights, alarm, doors, bonnet, boot, objective);
    else SetVehicleParamsEx(veh, 1, lights, alarm, doors, bonnet, boot, objective);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)