Lights are bugged!
#1

Well. I've worked abit on /carlights and I have a problem. Lights are working only on dark when I turn them on or when I step out of the vehicle. Basiclly I can write /carlights while being day and it doesn't work-. just when its dark!

What I did wrong?

Command:

pawn Code:
COMMAND:carlights(playerid,params[])
{
    if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new veh = GetPlayerVehicleID(playerid);
        new param[7];
        GetVehicleParamsEx(veh,param[0],param[1],param[2],param[3],param[4],param[5],param[6]);
        {
            if(!param[1])
            {
           
                StartLights(veh);
                SendEmote(playerid,"presses an button behind the steering wheel to turn on the lights.");
                return 1;
               
            }
            else
            {
           
                StartLights(veh);
                SendEmote(playerid,"presses an button behind the steering wheel to turn off the lights.");
                return 1;
               
            }
           
        }

    }
    else
    {
   
        SendErrorMsg(playerid,"You are not in a vehicle.");
        return 1;
       
    }

}



StartLights and StopLights!
pawn Code:
public StopLights(vehicleid)
{
    new params[7];
    GetVehicleParamsEx(vehicleid,params[0],params[1],params[2],params[3],params[4],params[5],params[6]);
    SetVehicleParamsEx(vehicleid,params[0],0,params[2],params[3],params[4],params[5],params[6]);
}

public StartLights(vehicleid)
{
    new params[7];
    GetVehicleParamsEx(vehicleid,params[0],params[1],params[2],params[3],params[4],params[5],params[6]);
    SetVehicleParamsEx(vehicleid,params[0],1,params[2],params[3],params[4],params[5],params[6]);

}
Reply
#2

Try and use this command and let me know if it fixes it?

Code:
CMD:carlights(playerid, params[])
{
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 1;
    new variables[7], vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(vehicleid, variables[0], variables[1], variables[2], variables[3], variables[4], variables[5], variables[6]);
    if(variables[1] != VEHICLE_PARAMS_ON)
    {
        SetVehicleParamsEx(vehicleid, variables[0], VEHICLE_PARAMS_ON, variables[2], variables[3], variables[4], variables[5], variables[6]);
    }
    else
    {
        SetVehicleParamsEx(vehicleid, variables[0], VEHICLE_PARAMS_OFF, variables[2], variables[3], variables[4], variables[5], variables[6]);
    }
    return 1;
}
Reply
#3

Why do you have all that shit? Lol
pawn Code:
CMD:carlights(playerid,params[])
{
    if(GetPlayerState(playerid) == 2)
    {
        new veh = GetPlayerVehicleID(playerid);
        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(veh,  engine, lights, alarm, doors, bonnet, boot, objective);
        {
            if(lights == 0)
            {
           
                SetVehicleParamsEx(veh,  engine, 1, alarm, doors, bonnet, boot, objective);
                SendEmote(playerid,"presses an button behind the steering wheel to turn on the lights.");
                return 1;
               
            }
            else
            {
           
                SetVehicleParamsEx(veh,  engine, 0, alarm, doors, bonnet, boot, objective);
                SendEmote(playerid,"presses an button behind the steering wheel to turn off the lights.");
                return 1;
               
            }
           
        }

    }
    else
    {
   
        SendErrorMsg(playerid,"You are not in a vehicle.");
        return 1;
       
    }

}
Also make sure to have this in OnGameModeInit()
pawn Code:
ManualVehicleEngineAndLights();
Reply
#4

Put this under public gamemodeinit ()
Code:
ManualVehicleEngineAndLights();
Reply
#5

Here we go budy a whole set

PHP Code:
CMD:car(playeridparams[])
{
    if(
isnull(params))
    {
        
SendClientMessageEx(playeridCOLOR_WHITE"USAGE: /car [name]");
        
SendClientMessageEx(playeridCOLOR_GREY"Available names: Status, Engine, Lights, Trunk, Hood, Fuel");
        return 
1;
    }
    if(
strcmp(params"engine"true) == && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new 
engine,lights,alarm,doors,bonnet,boot,objective,vehicleid;
        
vehicleid GetPlayerVehicleID(playerid);
        if(
GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
        
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(
engine == VEHICLE_PARAMS_ON)
        {
            
SetVehicleEngine(vehicleidplayerid);
        }
        else if((
engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET))
        {
            
SendClientMessageEx(playeridCOLOR_WHITE"Vehicle engine starting, please wait...");
            
SetTimerEx("SetVehicleEngine"10000"dd",  vehicleidplayerid);
        }
    }
    else if(
strcmp(params"lights"true) == && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new 
vehicleid GetPlayerVehicleID(playerid);
        if(
GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
        
SetVehicleLights(vehicleidplayerid);
    }
    else if(
strcmp(params"hood"true) == && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        if(
IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new 
vehicleid GetPlayerVehicleID(playerid);
            if(
GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510 || IsAPlane(vehicleid) || IsABike(vehicleid))
            {
                return 
SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
            }
            
SetVehicleHood(vehicleidplayerid);
        }
        else if(!
IsPlayerInAnyVehicle(playerid))
        {
            new 
closestcar GetClosestCar(playerid);
            if(
IsPlayerInRangeOfVehicle(playeridclosestcar5.0))
            {
                if(
GetVehicleModel(closestcar) == 481 || GetVehicleModel(closestcar) == 509 || GetVehicleModel(closestcar) == 510 || IsAPlane(closestcar) || IsABike(closestcar))
                {
                    return 
SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used on this vehicle.");
                }
                
SetVehicleHood(closestcarplayerid);
            }
        }
    }
    else if(
strcmp(params"trunk"true) == 0)
      {
        if(
IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new 
vehicleid GetPlayerVehicleID(playerid);
            if(
GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510)
            {
                return 
SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
            }
            
SetVehicleTrunk(vehicleidplayerid);
        }
        else if(!
IsPlayerInAnyVehicle(playerid))
        {
            new 
closestcar GetClosestCar(playerid);
            if(
IsPlayerInRangeOfVehicle(playeridclosestcar5.0))
            {
                if(
GetVehicleModel(closestcar) == 481 || GetVehicleModel(closestcar) == 509 || GetVehicleModel(closestcar) == 510)
                {
                    return 
SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used on this vehicle.");
                }
                
SetVehicleTrunk(closestcarplayerid);
            }
        }
    }
     else if(
strcmp(params"fuel"true) == && IsPlayerInAnyVehicle(playerid))
    {
        if(
GetVehicleModel(GetPlayerVehicleID(playerid)) == 481 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 510) return SendClientMessageEx(playerid,COLOR_RED,"This vehicle doesn't need fuel.");
        if(
GetPVarInt(playerid"fuelonoff") == 0)
        {
            
SendClientMessageEx(playeridCOLOR_WHITE"You have turned on the fuel indicator (green bar).");
            
SetPVarInt(playerid"fuelonoff"1);
            
FuelBar[playerid] = CreateProgressBar(548.0026.0057.503.20866792447100.0);
            
textdrawscount++;
            
SetProgressBarValue(FuelBar[playerid], VehicleFuel[GetPlayerVehicleID(playerid)]);
            
ShowProgressBarForPlayer(playeridFuelBar[playerid]);
        }
        else
        {
            
SendClientMessageEx(playeridCOLOR_WHITE"You have turned off the fuel indicator (green bar).");
            
SetPVarInt(playerid"fuelonoff"0);
            
DestroyProgressBar(FuelBar[playerid]);
            
textdrawscount--;
            
FuelBar[playerid] = INVALID_BAR_ID;
        }
    }
    else if(
strcmp(params"status"true) == 0)
    {
        if(
IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new 
vehicleid GetPlayerVehicleID(playerid);
            new 
engine,lights,alarm,doors,bonnet,boot,objective,enginestatus[4],lightstatus[4], string[48];
            
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
            if(
GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_RED,"This vehicle doesn't need fuel.");
            if(
engine != VEHICLE_PARAMS_ONformat(enginestatussizeof(enginestatus), "OFF");
            else 
format(enginestatussizeof(enginestatus), "ON");
            if(
lights != VEHICLE_PARAMS_ONformat(lightstatussizeof(lightstatus), "OFF");
            else 
format(lightstatussizeof(lightstatus), "ON");
            
format(stringsizeof(string), "Engine: %s | Lights: %s | Fuel: %.2f.",enginestatus,lightstatus,VehicleFuel[vehicleid]);
            
SendClientMessageEx(playeridCOLOR_WHITEstring);
        }
    }
    return 
1;

Kinds and Best Regards,
Thomas Williams Owner of Operation Roleplay, Stats Below \/ \/
Reply
#6

Quote:
Originally Posted by thomaswilliams
View Post
Here we go budy a whole set

PHP Code:
CMD:car(playeridparams[])
{
    if(
isnull(params))
    {
        
SendClientMessageEx(playeridCOLOR_WHITE"USAGE: /car [name]");
        
SendClientMessageEx(playeridCOLOR_GREY"Available names: Status, Engine, Lights, Trunk, Hood, Fuel");
        return 
1;
    }
    if(
strcmp(params"engine"true) == && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new 
engine,lights,alarm,doors,bonnet,boot,objective,vehicleid;
        
vehicleid GetPlayerVehicleID(playerid);
        if(
GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
        
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(
engine == VEHICLE_PARAMS_ON)
        {
            
SetVehicleEngine(vehicleidplayerid);
        }
        else if((
engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET))
        {
            
SendClientMessageEx(playeridCOLOR_WHITE"Vehicle engine starting, please wait...");
            
SetTimerEx("SetVehicleEngine"10000"dd",  vehicleidplayerid);
        }
    }
    else if(
strcmp(params"lights"true) == && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new 
vehicleid GetPlayerVehicleID(playerid);
        if(
GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
        
SetVehicleLights(vehicleidplayerid);
    }
    else if(
strcmp(params"hood"true) == && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        if(
IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new 
vehicleid GetPlayerVehicleID(playerid);
            if(
GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510 || IsAPlane(vehicleid) || IsABike(vehicleid))
            {
                return 
SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
            }
            
SetVehicleHood(vehicleidplayerid);
        }
        else if(!
IsPlayerInAnyVehicle(playerid))
        {
            new 
closestcar GetClosestCar(playerid);
            if(
IsPlayerInRangeOfVehicle(playeridclosestcar5.0))
            {
                if(
GetVehicleModel(closestcar) == 481 || GetVehicleModel(closestcar) == 509 || GetVehicleModel(closestcar) == 510 || IsAPlane(closestcar) || IsABike(closestcar))
                {
                    return 
SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used on this vehicle.");
                }
                
SetVehicleHood(closestcarplayerid);
            }
        }
    }
    else if(
strcmp(params"trunk"true) == 0)
      {
        if(
IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new 
vehicleid GetPlayerVehicleID(playerid);
            if(
GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510)
            {
                return 
SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
            }
            
SetVehicleTrunk(vehicleidplayerid);
        }
        else if(!
IsPlayerInAnyVehicle(playerid))
        {
            new 
closestcar GetClosestCar(playerid);
            if(
IsPlayerInRangeOfVehicle(playeridclosestcar5.0))
            {
                if(
GetVehicleModel(closestcar) == 481 || GetVehicleModel(closestcar) == 509 || GetVehicleModel(closestcar) == 510)
                {
                    return 
SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used on this vehicle.");
                }
                
SetVehicleTrunk(closestcarplayerid);
            }
        }
    }
     else if(
strcmp(params"fuel"true) == && IsPlayerInAnyVehicle(playerid))
    {
        if(
GetVehicleModel(GetPlayerVehicleID(playerid)) == 481 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 510) return SendClientMessageEx(playerid,COLOR_RED,"This vehicle doesn't need fuel.");
        if(
GetPVarInt(playerid"fuelonoff") == 0)
        {
            
SendClientMessageEx(playeridCOLOR_WHITE"You have turned on the fuel indicator (green bar).");
            
SetPVarInt(playerid"fuelonoff"1);
            
FuelBar[playerid] = CreateProgressBar(548.0026.0057.503.20866792447100.0);
            
textdrawscount++;
            
SetProgressBarValue(FuelBar[playerid], VehicleFuel[GetPlayerVehicleID(playerid)]);
            
ShowProgressBarForPlayer(playeridFuelBar[playerid]);
        }
        else
        {
            
SendClientMessageEx(playeridCOLOR_WHITE"You have turned off the fuel indicator (green bar).");
            
SetPVarInt(playerid"fuelonoff"0);
            
DestroyProgressBar(FuelBar[playerid]);
            
textdrawscount--;
            
FuelBar[playerid] = INVALID_BAR_ID;
        }
    }
    else if(
strcmp(params"status"true) == 0)
    {
        if(
IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new 
vehicleid GetPlayerVehicleID(playerid);
            new 
engine,lights,alarm,doors,bonnet,boot,objective,enginestatus[4],lightstatus[4], string[48];
            
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
            if(
GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_RED,"This vehicle doesn't need fuel.");
            if(
engine != VEHICLE_PARAMS_ONformat(enginestatussizeof(enginestatus), "OFF");
            else 
format(enginestatussizeof(enginestatus), "ON");
            if(
lights != VEHICLE_PARAMS_ONformat(lightstatussizeof(lightstatus), "OFF");
            else 
format(lightstatussizeof(lightstatus), "ON");
            
format(stringsizeof(string), "Engine: %s | Lights: %s | Fuel: %.2f.",enginestatus,lightstatus,VehicleFuel[vehicleid]);
            
SendClientMessageEx(playeridCOLOR_WHITEstring);
        }
    }
    return 
1;

Kinds and Best Regards,
Thomas Williams Owner of Operation Roleplay, Stats Below \/ \/
thats not even gonna work, copy paste simply does not work.
Reply
#7

Another quick fix for this can be done by setting the in game weather to 2. Same happens with the lights on police cruisers/ambulances/fire trucks etc.

Also, regardless, make sure you have the above stated in the script too.
Reply
#8

Fixed! Thank you everybody!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)