01.12.2015, 15:36
You are complicating stuff too much.
Dont use yom_buttons, better make a textdraw instead and control it like that, or use the code above that Ive given you to have it simply with F or Enter button to open/close.
PHP Code:
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
new GateStatus;
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (PRESSED(KEY_SECONDARY_ATTACK)) { //If button is F or Enter
if(IsPlayerInRangeOfPoint(playerid,3,247.2763671875,72.536186218262,1002.640625)) { //if they are near PD
if(GateStatus == 0) { //if gate wasnt moved so far aka its on its default values
SetTimer("DoorOpen", 3500, 0); //or whatever you use to open your gates/doors
SendClientMessage(playerid,COLOR_RED,"You have opened PD gates");
GateStatus = 1;
}
else if(GateStatus == 1) { //If the gate was moved previously, aka someone used F near it to open it
SetTimer("DoorClose", 3500, 0); //or whatever you use to close your gates/doors
SendClientMessage(playerid,COLOR_RED,"You have closed PD gates");
GateStatus = 0;
}
}
}
return 1;
}