Keystroke Commands?
#1

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

Read this: https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Reply
#3

Thanks
Reply
#4

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");
			}
		}
	}
Reply
#5

Would someone please help me.. and sorry for tripple post.
Reply
#6

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;
			}
		}
	}
Reply
#7

Код:
	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 .
Reply
#8

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

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");
        }
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)