13.06.2015, 00:46
This should work I suppose:
References:
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
https://sampwiki.blast.hk/wiki/Keys
P.S. why don't you check distance on opening a gate like you do when closing one?
pawn Код:
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) // Detects player key state changes
{
if(PRESSED(2)) // If the horn key was pressed
{
if(IsPlayerInAnyVehicle(playerid)) // If this player is in a vehicle (seems legit?)
{
// Well, they pressed the horn key and they're in a vehicle, so let's process the gate script
if(!GateInfo[h][gStatus])
{
MoveObject(LSPDGate,1544.7018,-1630.9528,13.2196,0.0000,00.0000,90.0000);
SetObjectRot(LSPDGate, 0.0000, 0.0000, 90.0000 );
Action(playerid, "opens up the gate.");
GateInfo[h][gStatus]=1;
}
else if(PlayerToPoint(9.0,playerid,1544.6943, -1630.7305, 13.2796))
{
MoveObject(LSPDGate,1544.7018,-1630.9528,13.2196,0.0000,90.0000,90.0000);
SetObjectRot(LSPDGate, 0.0000, 90.0000, 90.0000 );
GateInfo[h][gStatus]=0;
Action(playerid, "closes up the gate.");
}
}
}
return 1;
}
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
https://sampwiki.blast.hk/wiki/Keys
P.S. why don't you check distance on opening a gate like you do when closing one?