SA-MP Forums Archive
Keystroke Commands? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Keystroke Commands? (/showthread.php?tid=113044)



Keystroke Commands? - External-Life - 12.12.2009

How would you add a command that by using the shift key or what ever that it does what ever i want it to?


Re: Keystroke Commands? - Zeex - 12.12.2009

Read this: https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange


Re: Keystroke Commands? - External-Life - 12.12.2009

Thanks


Re: Keystroke Commands? - External-Life - 12.12.2009

Sorry for double posting :S ok so i got the command working and all but... like i made it to where when you hit the jump key you start the engine cause i have a engine script in my server now it works until you hit your brake key can you help me out??

heres the code
Код:
	if (PRESSED(KEY_JUMP))
	{
		if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		{
		  if(EngineStatus[GetPlayerVehicleID(playerid)] == 0)
			{
				TogglePlayerControllable(playerid,1);
				EngineStatus[GetPlayerVehicleID(playerid)] = 1;
				PlayerActionMessage(playerid,15.0,"turns on the engine");
			}
			else
			{
				TogglePlayerControllable(playerid,0);
				EngineStatus[GetPlayerVehicleID(playerid)] = 0;
				PlayerActionMessage(playerid,15.0,"turns off the engine");
			}
		}
	}



Re: Keystroke Commands? - External-Life - 14.12.2009

Would someone please help me.. and sorry for tripple post.


Re: Keystroke Commands? - Damon_Black - 14.12.2009

No idea what you mean by brake key but try this. Without any returns the EngineStatus is IF and ELSE. At least that's my guess based on what you said.

Код:
if (PRESSED(KEY_JUMP))
	{
		if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		{
		  if(EngineStatus[GetPlayerVehicleID(playerid)] == 0)
			{
				TogglePlayerControllable(playerid,1);
				EngineStatus[GetPlayerVehicleID(playerid)] = 1;
				PlayerActionMessage(playerid,15.0,"turns on the engine");
                return 1;
			}
			else
			{
				TogglePlayerControllable(playerid,0);
				EngineStatus[GetPlayerVehicleID(playerid)] = 0;
				PlayerActionMessage(playerid,15.0,"turns off the engine");
                return 1;
			}
		}
	}



Re: Keystroke Commands? - Deat_Itself - 14.12.2009

Код:
	if (PRESSED(KEY_JUMP))
	{
if(IsPlayerInAnyVehicle(playerid)) {
		if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		{
		  if(EngineStatus[GetPlayerVehicleID(playerid)] == 0)
			{
				TogglePlayerControllable(playerid,1);
				EngineStatus[GetPlayerVehicleID(playerid)] = 1;
				PlayerActionMessage(playerid,15.0,"turns on the engine");
			}
			else
			{
				EngineStatus[GetPlayerVehicleID(playerid)] = 0;
				PlayerActionMessage(playerid,15.0,"turns off the engine");
			}
		}
	}
try this it should work and i havent tested it ,if there is any bug so kindly tell me .


Re: Keystroke Commands? - External-Life - 16.12.2009

k well ive had time to test it and none of those solutions work


Re: Keystroke Commands? - Chaprnks - 16.12.2009

Try this:
pawn Код:
// PRESSING(newkeys, keys)
#define PRESSING(%0,%1) \
    (((%0) & (%1)) == (%1))
pawn Код:
if(PRESSING(newkeys, KEY_SPRINT) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
         if(EngineStatus[GetPlayerVehicleID(playerid)] == 0)
        {
            TogglePlayerControllable(playerid,1);
            EngineStatus[GetPlayerVehicleID(playerid)] = 1;
            PlayerActionMessage(playerid,15.0,"turns on the engine");
        }
        else if(EngineStatus[GetPlayerVehicleID(playerid)] == 1)
        {
            TogglePlayerControllable(playerid,0);
            EngineStatus[GetPlayerVehicleID(playerid)] = 0;
            PlayerActionMessage(playerid,15.0,"turns off the engine");
        }
    }