Incearca unul din aceste coduri:
Prima este cum as scripta eu faza asta.
PS: Nu stiu la ce iti trebuie variabila Lights asa ca ti-o las acolo.
PHP код:
if(newkeys & KEY_CROUCH) //Aici pare OK
{
new engine, lights, alarm, doors, bonnet, boot, objective,veh = GetPlayerVehicleID;
GetVehicleParamsEx(veh, engine, lights, alarm, doors, bonnet, boot, objective); // Astea doua rande le poti gasi si pe wiki
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && engine == 1) //engine == 1 inseamna: "Daca motorul este pornit". Daca este in PLAYER_STATE_DRIVER este deja intr-o masina.
{
if(lights == 0) //"Daca farurile sunt stinse"
{
GameTextForPlayer(playerid, "lights: ~g~on", 1000,3);
GetVehicleParamsEx(veh, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsVeh(veh, engine, 1, alarm, doors, bonnet, boot, objective);
Lights[veh] = 1 //Asta nu stiu la ce iti trebuie, il las aici ca poate ai nevoie de el.
}
else
{
GameTextForPlayer(playerid, "lights: ~r~off", 1000,3);
GetVehicleParamsEx(veh, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsVeh(veh, engine, 0, alarm, doors, bonnet, boot, objective);
Lights[veh]= 0 //La fel ca la celalalt Lights, nu stiu la ce iti trebuie
}
}
}
Si asta e varianta ta, facuta cum, presupun, te gandeai sa fie.
PHP код:
if(newkeys & KEY_CROUCH)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && Engine[GetPlayerVehicleID(playerid)] == 1)
{
new veh = GetPlayerVehicleID(playerid);
if(Lights[veh] == 0)
{
GameTextForPlayer(playerid, "lights: ~g~on", 1000,3);
GetVehicleParamsEx(veh, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsVeh(veh, engine, 1, alarm, doors, bonnet, boot, objective);
Lights[veh] = 1;
}
else
{
GameTextForPlayer(playerid, "lights: ~r~off", 1000,3);
GetVehicleParamsEx(veh, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsVeh(veh, engine, 0, alarm, doors, bonnet, boot, objective);
Lights[veh] = 0;
}
}
}