10.02.2012, 17:47
I want,when I am in a car,with a buttons press, to turn on/off the carlights. could you help me?
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (PRESSED(KEY_SUBMISSION/* Button 2 */) && IsPlayerInAnyVehicle(playerid)) {
new vehicleid = GetPlayerVehicleID(playerid), turnTo;
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
turnTo = (lights == 0) ? (1) : (0);
SetVehicleParamsEx(vehicleid, engine, turnTo, alarm, doors, bonnet, boot, objective);
}
return 1;
}