Making Gate Movable for Horn
#2

This should work I suppose:

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


Messages In This Thread
Making Gate Movable for Horn - by Magnezia - 12.06.2015, 23:45
Re: Making Gate Movable for Horn - by [KHK]Khalid - 13.06.2015, 00:46
Re: Making Gate Movable for Horn - by Abagail - 13.06.2015, 01:14
Re: Making Gate Movable for Horn - by [KHK]Khalid - 13.06.2015, 01:27
Re: Making Gate Movable for Horn - by Magnezia - 13.06.2015, 02:09
Re: Making Gate Movable for Horn - by Abagail - 13.06.2015, 02:31
Re: Making Gate Movable for Horn - by [KHK]Khalid - 13.06.2015, 02:45

Forum Jump:


Users browsing this thread: 1 Guest(s)