why dosent work ? -
[Nikk] - 25.01.2012
Hey, i wanna made when a player press "2" turn on the lights, and when the player press "2" again, the lights turn OFF, the problem is what the lights dosent turn OFF, why ?
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine,lights,alarm,doors,bonnet,boot,objective;
if ((newkeys & KEY_SUBMISSION) && !(oldkeys & KEY_SUBMISSION))
{
if(IsPlayerInVehicle(playerid, vehicleid))
{
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,engine,true,alarm,doors,bonnet,boot,objective);
} else SetVehicleParamsEx(vehicleid,engine,false,alarm,doors,bonnet,boot,objective);
}
return 1;
}

?

?
Re: why dosent work ? -
[XST]O_x - 25.01.2012
Notice the changes:
pawn Код:
if ((newkeys & KEY_SUBMISSION) && !(oldkeys & KEY_SUBMISSION))
{
if(IsPlayerInVehicle(playerid, vehicleid))
{
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,engine,true,alarm,doors,bonnet,boot,objective);
}
else
{
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective); //Was missing
SetVehicleParamsEx(vehicleid,engine,false,alarm,doors,bonnet,boot,objective);
}
return 1;
}
Respuesta: why dosent work ? -
[Nikk] - 25.01.2012
Thanks men.
Re: why dosent work ? -
Babul - 25.01.2012
?? is that code supposed to work? i mean, if a player is not in a vehicle, then the lights may get switched off? how can a player not be in a vehicle, and turn off its lights?
lights=0; 1-lights=1;
lights=1; 1-lights=0;
so you can do:
pawn Код:
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,engine,1-lights,alarm,doors,bonnet,boot,objective);
.. also saves an if-else check as little bonus, heh