[pawn]#define PRESSED(%0) \ (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0))) //For more information about PRESSED: http://wiki.sa-mp.com/wiki/OnPlayerKeyStateChange public OnPlayerKeyStateChange(playerid,newkeys,oldkeys) { switch(PRESSED)//Always use switch { case KEY_HANDBRAKE://(Hand Brake/aim) { if(IsPlayerInRangeOfPoint(playerid,10,xxx,yyy,zzz)//Gate 1 { switch(Open{0})//Check whether the gate opened or closed { case true://If the gate opened { MoveObject(Gate[0],Float:X,Float:Y,Float:Z,Float:Speed);//Close the gate Open{0} == false;//false for closed } case false://If the gate closed { MoveObject(Gate[0],Float:X,Float:Y,Float:Z,Float:Speed);//Open the gate Open{0} == true;//true for opened } } } else if(IsPlayerInRangeOfPoint(playerid,10,xxx,yyy,zzz)//Gate 2 { switch(Open{1})//Check whether the gate opened or closed { case true://If the gate opened { MoveObject(Gate[1],Float:X,Float:Y,Float:Z,Float:Speed);//Close the gate Open{1} == false;//false for closed } case false://If the gate closed { MoveObject(Gate[2],Float:X,Float:Y,Float:Z,Float:Speed);//Open the gate Open{1} == true;//true for opened } } } else if(IsPlayerInRangeOfPoint(playerid,10,xxx,yyy,zzz)//Gate 3 { switch(Open{2})//Check whether the gate opened or closed { case true://If the gate opened { MoveObject(Gate[3],Float:X,Float:Y,Float:Z,Float:Speed);//Close the gate Open{2} == false;//false for closed } case false://If the gate closed { MoveObject(Gate[3],Float:X,Float:Y,Float:Z,Float:Speed);//Open the gate Open{2} == true;//true for opened } } } } } return 1; }[/pawn] Sursa: http://forum.sa-mp.com/showthread.php?t=278880