Vehicle Lights Bug
#1

I got into the vehicle and typed /light command, then the vehicle lights did not turn on, but when I got off the vehicle, the vehicle lights turned on. When I ride it again, the vehicle lights do not turn on again. Why did it happen? even though I'm sure my code is correct..

PHP код:
SwitchVehicleLight(vehicleidplayerid)
{
    new 
vengine,vlights,valarm,vdoors,vbonnet,vboot,vobjective;
    
GetVehicleParamsEx(vehicleid,vengine,vlights,valarm,vdoors,vbonnet,vboot,vobjective);
    if(
vlights == VEHICLE_PARAMS_OFF)
    {
        
SetVehicleParamsEx(vehicleid,vengine,VEHICLE_PARAMS_ON,valarm,vdoors,vbonnet,vboot,vobjective);
        
SCM(playeridCOLOR_LIGHTBLUE"[Vehicle] {FFFFFF}Lampu mobil telah dinyalakan."); //Turn On
    
}
    else
    {
        
SetVehicleParamsEx(vehicleid,vengine,VEHICLE_PARAMS_OFF,valarm,vdoors,vbonnet,vboot,vobjective);
        
SCM(playeridCOLOR_LIGHTBLUE"[Vehicle] {FFFFFF}Lampu mobil telah dimatikan."); //Turn Off
    
}
}
CMD:light(playeridparams[])
{
    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.");
        
SwitchVehicleLight(vehicleidplayerid);
    }
    return 
1;
}
public 
OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    
//new vengine, vlights, valarm, vdoors, vbonnet, vboot, vobjective;
    //GetVehicleParamsEx(vehicleid, vengine, vlights, valarm, vdoors, vbonnet, vboot, vobjective);
    
new vengine GetVehicleParams(vehicleidVEHICLE_TYPE_ENGINE);
    if(
vengine == VEHICLE_PARAMS_UNSET
    {
        switch(
GetVehicleModel(vehicleid))
        {
            
//case 481, 510: vehEngine{vehicleid} = 1, SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,vlights,valarm,vdoors,vbonnet,vboot,vobjective);
            //default: SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_OFF, vlights, valarm, vdoors, vbonnet, vboot, vobjective), vehEngine{vehicleid} = 0;
            
case 481510vehEngine{vehicleid} = 1SetVehicleParams(vehicleidVEHICLE_TYPE_ENGINEVEHICLE_PARAMS_ON0);
            default: 
SetVehicleParams(vehicleidVEHICLE_TYPE_ENGINEVEHICLE_PARAMS_OFF0), vehEngine{vehicleid} = 0;
        }
    }
    return 
0;

Please I need your help guys :'
Reply
#2

bump
Reply
#3

up up
Reply
#4

Solved.
I just need to put
PHP код:
ManualVehicleEngineAndLights(); 
into OnGameModeInit();
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)