help with /light
#4

Код:
#include <a_samp>
#define PRESSED(%0) \
        (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
		
new bool: VehicleLightsOn[MAX_VEHICLES];

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if (newstate == PLAYER_STATE_DRIVER)
	{
		if (VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
		{
			new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
			GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
			SetVehicleParamsEx(vid, engine, 0, alarm, doors, bonnet, boot, objective);
		}
		else
		{
			new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
			GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
			SetVehicleParamsEx(vid, engine, 1, alarm, doors, bonnet, boot, objective);
		}
	}
	return 1;
}
 
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if (PRESSED(KEY_ACTION))
	{
		if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		{
			if (VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
			{
				new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
				GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
				SetVehicleParamsEx(vid, engine, 1, alarm, doors, bonnet, boot, objective);			
				VehicleLightsOn[vid] = true;
			}
			else
			{
				new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
				GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
				SetVehicleParamsEx(vid, engine, 0, alarm, doors, bonnet, boot, objective);			
				VehicleLightsOn[vid] = false;
			}
		}
	}
	return 1;
}
That should work.
Reply


Messages In This Thread
help with /light - by Dan_Barocu - 01.01.2012, 15:21
Re: help with /light - by James Coral - 01.01.2012, 15:27
Re: help with /light - by Dan_Barocu - 01.01.2012, 15:37
Re: help with /light - by Basssiiie - 01.01.2012, 16:03
Re: help with /light - by Dan_Barocu - 01.01.2012, 16:05
Re: help with /light - by Basssiiie - 01.01.2012, 16:05
Re: help with /light - by Dan_Barocu - 01.01.2012, 16:09
Re: help with /light - by Mosslah - 01.01.2012, 16:11
Re: help with /light - by Dan_Barocu - 01.01.2012, 16:14
Re: help with /light - by Mosslah - 01.01.2012, 16:18

Forum Jump:


Users browsing this thread: 1 Guest(s)