SA-MP Forums Archive
Vehicle Lights Bug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Vehicle Lights Bug (/showthread.php?tid=660660)



Vehicle Lights Bug - AlfaSufaIndo - 09.11.2018

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(vehicleid, playerid)
{
    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(playerid, COLOR_LIGHTBLUE, "[Vehicle] {FFFFFF}Lampu mobil telah dinyalakan."); //Turn On
    
}
    else
    {
        
SetVehicleParamsEx(vehicleid,vengine,VEHICLE_PARAMS_OFF,valarm,vdoors,vbonnet,vboot,vobjective);
        
SCM(playerid, COLOR_LIGHTBLUE, "[Vehicle] {FFFFFF}Lampu mobil telah dimatikan."); //Turn Off
    
}
}
CMD:light(playerid, params[])
{
    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(vehicleid, playerid);
    }
    return 
1;
}
public 
OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    
//new vengine, vlights, valarm, vdoors, vbonnet, vboot, vobjective;
    //GetVehicleParamsEx(vehicleid, vengine, vlights, valarm, vdoors, vbonnet, vboot, vobjective);
    
new vengine = GetVehicleParams(vehicleid, VEHICLE_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 481, 510: vehEngine{vehicleid} = 1, SetVehicleParams(vehicleid, VEHICLE_TYPE_ENGINE, VEHICLE_PARAMS_ON, 0);
            default: 
SetVehicleParams(vehicleid, VEHICLE_TYPE_ENGINE, VEHICLE_PARAMS_OFF, 0), vehEngine{vehicleid} = 0;
        }
    }
    return 
0;
} 
Please I need your help guys :'


Re: Vehicle Lights Bug - AlfaSufaIndo - 09.11.2018

bump


Re: Vehicle Lights Bug - AlfaSufaIndo - 10.11.2018

up up


Re: Vehicle Lights Bug - AlfaSufaIndo - 10.11.2018

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