09.11.2018, 16:24
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..
Please I need your help guys :'
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;
}