Hotkey Help
#1

Hi i have A Command , How Use Hotkey 2 For That command ? My Command is :

Код:
	if(!strcmp(cmd, "/engine", true))
	{
		new vid = GetPlayerVehicleID(playerid);
		if(LockEngine[vid] == true) return SCM(playerid, COLOR_LIGHTRED, "Another admin locked the engine of this vehicle.");
		if(Refueling[playerid] >= 1)
		{
			SCM(playerid,COLOR_LIGHTGREEN,"GasStation: Wait for vehicle refuel successfully.");
			return 1;
		}
		if((OwnedMashin[vid] == 1 && PINFO[MashinOwner[vid]][cFixed] != 1) || (OwnedMashin_2[vid] == 1 && PINFO[MashinOwner_2[vid]][cFixed_2] != 1))
		{
			return 1;
		}
		if(OnRentMashinMessage[playerid] == true) return 1;
	    if(IsPlayerConnected(playerid))
	    {
			if(IsPlayerInAnyVehicle(playerid))
			{
				if(Benzin[vid] == 0)
				{
					SCM(playerid,COLOR_LIGHTGREEN,"No fuel in vehicle, Call a mechanic with /service mechanic or buy a gas can");
               		GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
               		SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
               		EngineSTATE[vid] = 0;
					return 1;
				}
	 		    if(!engineOn[GetPlayerVehicleID(playerid)])
 		        {
		        	if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
					{
						return 1;
					}
					if(pveh == 510 || pveh == 481 || pveh == 509)
					{
						SCM(playerid,COLOR_LIGHTBLUE,"can't stop engine or start for bikes, its already start of Engine on.");
						GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
		               	SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
		               	EngineSTATE[vid] = 1;
						return 1;
					}
	                if(vid == 31 || vid == 32 || vid == 33 || vid == 34 || vid == 35 || vid == bullet1 || vid == bullet2)
					{
						new playerveh = GetPlayerVehicleID(playerid);
						new vehicles = GetVehicleModel(playerveh) - 400;
					    if(EngineSTATE[vid] == 0)
	            		{
	               			GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
	               			SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
	               			EngineSTATE[vid] = 1;
	               			GetPlayerName(playerid, sendername, sizeof(sendername));
	               			TogglePlayerControllable(playerid, 1);
	                        format(string, sizeof(string), "%s starts the engine of the Police %s.", sendername,aVehicleNames[vehicles]);
					        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
					        if(OnSpeedc[playerid] == 1)
							{
								KillTimer(SpeedTimer[playerid]);
								SpeedTimerUsed[playerid] = false;
								SpeedTimer[playerid] = 0;
								OnSpeedc[playerid] = 0;
								SCM(playerid,COLOR_ALI,"Speed Camera {FFFFFF}Disabled.");
							}
					 		return 1;
	            		}
	            		else
	            		{
	               			GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
	               			SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
	               			EngineSTATE[vid] = 0;
	               			GetPlayerName(playerid, sendername, sizeof(sendername));
	               			format(string, sizeof(string), "%s stops the engine of the Police %s.", sendername,aVehicleNames[vehicles]);
				            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				            if(OnSpeedc[playerid] == 1)
							{
								KillTimer(SpeedTimer[playerid]);
								SpeedTimerUsed[playerid] = false;
								SpeedTimer[playerid] = 0;
								OnSpeedc[playerid] = 0;
								SCM(playerid,COLOR_ALI,"Speed Camera {FFFFFF}Disabled.");
							}
				            return 1;
						}
					}
                    new playerveh = GetPlayerVehicleID(playerid);
				    new vehicles = GetVehicleModel(playerveh) - 400;
            		if(EngineSTATE[vid] == 0)
            		{
               			GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
               			SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
               			EngineSTATE[vid] = 1;
               			GetPlayerName(playerid, sendername, sizeof(sendername));
               			TogglePlayerControllable(playerid, 1);
                        format(string, sizeof(string), "%s starts the engine of the %s.", sendername,aVehicleNames[vehicles]);
				        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				        if(OnSpeedc[playerid] == 1)
						{
							KillTimer(SpeedTimer[playerid]);
							SpeedTimerUsed[playerid] = false;
							SpeedTimer[playerid] = 0;
							OnSpeedc[playerid] = 0;
							SCM(playerid,COLOR_ALI,"Speed Camera {FFFFFF}Disabled.");
						}
            		}
            		else
            		{
               			GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
               			SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
               			EngineSTATE[vid] = 0;
               			GetPlayerName(playerid, sendername, sizeof(sendername));
               			format(string, sizeof(string), "%s stops the engine of the %s.", sendername,aVehicleNames[vehicles]);
			            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				        if(OnSpeedc[playerid] == 1)
						{
							KillTimer(SpeedTimer[playerid]);
							SpeedTimerUsed[playerid] = false;
							SpeedTimer[playerid] = 0;
							OnSpeedc[playerid] = 0;
							SCM(playerid,COLOR_ALI,"Speed Camera {FFFFFF}Disabled.");
						}
					}
				}
			}
		}
		return 1;
	}
Please Help Me i need Your Help
Reply
#2

Use 'OnPlayerKeyStateChange'.

At the top of your script:
Код:
#define PRESSED(%0) \
(((newkeys&(%0))==(%0)) && ((oldkeys & (%0)) != (%0)))
Under OnPlayerKeyStateChange
Код:
if(PRESSED(KEY_SUBMISSION)) // Key number '2'. Not numpad 2.
{
    //code here
    return 1;
}
Reply
#3

Код:
if(PRESSED(KEY_SUBMISSION)) // Key number '2'. Not numpad 2.
{
    if(!strcmp(cmd, "/engine", true))
	{
		new vid = GetPlayerVehicleID(playerid);
		if(LockEngine[vid] == true) return SCM(playerid, COLOR_LIGHTRED, "Another admin locked the engine of this vehicle.");
		if(Refueling[playerid] >= 1)
		{
			SCM(playerid,COLOR_LIGHTGREEN,"GasStation: Wait for vehicle refuel successfully.");
			return 1;
		}
		if((OwnedMashin[vid] == 1 && PINFO[MashinOwner[vid]][cFixed] != 1) || (OwnedMashin_2[vid] == 1 && PINFO[MashinOwner_2[vid]][cFixed_2] != 1))
		{
			return 1;
		}
		if(OnRentMashinMessage[playerid] == true) return 1;
	    if(IsPlayerConnected(playerid))
	    {
			if(IsPlayerInAnyVehicle(playerid))
			{
				if(Benzin[vid] == 0)
				{
					SCM(playerid,COLOR_LIGHTGREEN,"No fuel in vehicle, Call a mechanic with /service mechanic or buy a gas can");
               		GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
               		SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
               		EngineSTATE[vid] = 0;
					return 1;
				}
	 		    if(!engineOn[GetPlayerVehicleID(playerid)])
 		        {
		        	if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
					{
						return 1;
					}
					if(pveh == 510 || pveh == 481 || pveh == 509)
					{
						SCM(playerid,COLOR_LIGHTBLUE,"can't stop engine or start for bikes, its already start of Engine on.");
						GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
		               	SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
		               	EngineSTATE[vid] = 1;
						return 1;
					}
	                if(vid == 31 || vid == 32 || vid == 33 || vid == 34 || vid == 35 || vid == bullet1 || vid == bullet2)
					{
						new playerveh = GetPlayerVehicleID(playerid);
						new vehicles = GetVehicleModel(playerveh) - 400;
					    if(EngineSTATE[vid] == 0)
	            		{
	               			GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
	               			SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
	               			EngineSTATE[vid] = 1;
	               			GetPlayerName(playerid, sendername, sizeof(sendername));
	               			TogglePlayerControllable(playerid, 1);
	                        format(string, sizeof(string), "%s starts the engine of the Police %s.", sendername,aVehicleNames[vehicles]);
					        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
					        if(OnSpeedc[playerid] == 1)
							{
								KillTimer(SpeedTimer[playerid]);
								SpeedTimerUsed[playerid] = false;
								SpeedTimer[playerid] = 0;
								OnSpeedc[playerid] = 0;
								SCM(playerid,COLOR_ALI,"Speed Camera {FFFFFF}Disabled.");
							}
					 		return 1;
	            		}
	            		else
	            		{
	               			GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
	               			SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
	               			EngineSTATE[vid] = 0;
	               			GetPlayerName(playerid, sendername, sizeof(sendername));
	               			format(string, sizeof(string), "%s stops the engine of the Police %s.", sendername,aVehicleNames[vehicles]);
				            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				            if(OnSpeedc[playerid] == 1)
							{
								KillTimer(SpeedTimer[playerid]);
								SpeedTimerUsed[playerid] = false;
								SpeedTimer[playerid] = 0;
								OnSpeedc[playerid] = 0;
								SCM(playerid,COLOR_ALI,"Speed Camera {FFFFFF}Disabled.");
							}
				            return 1;
						}
					}
                    new playerveh = GetPlayerVehicleID(playerid);
				    new vehicles = GetVehicleModel(playerveh) - 400;
            		if(EngineSTATE[vid] == 0)
            		{
               			GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
               			SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
               			EngineSTATE[vid] = 1;
               			GetPlayerName(playerid, sendername, sizeof(sendername));
               			TogglePlayerControllable(playerid, 1);
                        format(string, sizeof(string), "%s starts the engine of the %s.", sendername,aVehicleNames[vehicles]);
				        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				        if(OnSpeedc[playerid] == 1)
						{
							KillTimer(SpeedTimer[playerid]);
							SpeedTimerUsed[playerid] = false;
							SpeedTimer[playerid] = 0;
							OnSpeedc[playerid] = 0;
							SCM(playerid,COLOR_ALI,"Speed Camera {FFFFFF}Disabled.");
						}
            		}
            		else
            		{
               			GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
               			SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
               			EngineSTATE[vid] = 0;
               			GetPlayerName(playerid, sendername, sizeof(sendername));
               			format(string, sizeof(string), "%s stops the engine of the %s.", sendername,aVehicleNames[vehicles]);
			            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				        if(OnSpeedc[playerid] == 1)
						{
							KillTimer(SpeedTimer[playerid]);
							SpeedTimerUsed[playerid] = false;
							SpeedTimer[playerid] = 0;
							OnSpeedc[playerid] = 0;
							SCM(playerid,COLOR_ALI,"Speed Camera {FFFFFF}Disabled.");
						}
					}
				}
			}
		}
		return 1;
	}
    return 1;
}
this Okay ?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)