Having trouble opening the gate.
#1

I created a gate and made it so you press "F" it opens, but it only open if you hold F.
Код:
if(newkeys & 16)// at lv houses
    {
    	if(IsPlayerInRangeOfPoint(playerid, 2.0, 1574.45000000,666.05000000,11.31000000))//
     	{
    		if(checkgate[playerid] == 0)
			{   
				MoveObject(housegate, 1567.17000000,663.53000000,6.37000000,  2.0);
				GameTextForPlayer(playerid, "Gate ~g~opening", 5000, 6);
  				PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
       			ApplyAnimation(playerid, "HEIST9", "Use_SwipeCard", 10.0, 0, 0, 0, 0, 0);
   				checkgate[playerid]=1;
			}
		}
	}
	else
	{
		if(checkgate[playerid] == 1)
		{
			MoveObject(housegate, 1567.18000000,663.51000000,12.47000000, 2.0);
			GameTextForPlayer(playerid, "Gate ~r~closing", 5000, 6);
			checkgate[playerid]=0;
			PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
			ApplyAnimation(playerid, "HEIST9", "Use_SwipeCard", 10.0, 0, 0, 0, 0, 0);
		}
	}
        return 1;
}
Reply
#2

anyone?
Reply
#3

You need to use the oldkeys parameter as well, to check if the oldkeys do not contain the newkeys.

pawn Код:
if((newkeys & 16) && !(oldkeys & 16))
Refer to https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange for more information.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)