SA-MP Forums Archive
Help! how to close the doors? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help! how to close the doors? (/showthread.php?tid=225481)



Help! how to close the doors? - arjunaryas - 13.02.2011

How to close the doors in the below code, I want to close the the doors if the same key is pressed again.
And please don't suggest me any timer kind idea, I just want it to be closed by the same key again.
!Please help!

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_SECONDARY_ATTACK))
    if(IsPlayerInRangeOfPoint(playerid, 2.0, 3303.86743164,-1776.77416992,12.91423416))
{
    MoveObject(mygate, 3304.685546875,-1777.5478515625,8.7626247406006, 4.0);
        ApplyAnimation(playerid,"HEIST9","Use_SwipeCard",4.1,0,0,0,1,1,1);
   
}
    else {
   
    }
    return 1;

    }



Re: Help! how to close the doors? - Mean - 13.02.2011

Make a variable.

pawn Код:
new Doorsopened;
pawn Код:
public OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
{
    if( PRESSED( KEY_SECONDARY_ATTACK ) )
    {
        if( IsPlayerInRangeOfPoint( playerid, 2.0, 3303.86743164,-1776.77416992,12.91423416 ) )
        {
            if( Doorsopened == 0 )
            {
                Doorsopened = 1;
                MoveObject( mygate, 3304.685546875,-1777.5478515625,8.7626247406006, 4.0 );
                ApplyAnimation( playerid,"HEIST9","Use_SwipeCard",4 .1,0,0,0,1,1,1 );
            }
            else
            {
                Doorsopened = 0;
                //Your code to close the gates, moveobject.
            }
        }
    }
    return 1;
}
UNTESTED.


Re: Help! how to close the doors? - arjunaryas - 13.02.2011

Quote:
Originally Posted by Mean
Посмотреть сообщение
Make a variable.

pawn Код:
new Doorsopened;
pawn Код:
public OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
{
    if( PRESSED( KEY_SECONDARY_ATTACK ) )
    {
        if( IsPlayerInRangeOfPoint( playerid, 2.0, 3303.86743164,-1776.77416992,12.91423416 ) )
        {
            if( Doorsopened == 0 )
            {
                Doorsopened = 1;
                MoveObject( mygate, 3304.685546875,-1777.5478515625,8.7626247406006, 4.0 );
                ApplyAnimation( playerid,"HEIST9","Use_SwipeCard",4 .1,0,0,0,1,1,1 );
            }
            else
            {
                Doorsopened = 0;
                //Your code to close the gates, moveobject.
            }
        }
    }
    return 1;
}
UNTESTED.
Thanks! I am going to test it.


Re: Help! how to close the doors? - Mean - 13.02.2011

Okay, tell me if it worked .
But, under the else, as I said in the comment, put the closing code, don't just copy and paste it, and go like that.


Re: Help! how to close the doors? - arjunaryas - 13.02.2011

Quote:
Originally Posted by Mean
Посмотреть сообщение
Okay, tell me if it worked .
But, under the else, as I said in the comment, put the closing code, don't just copy and paste it, and go like that.
I love you man! Now it works, !many many thanks!


Re: Help! how to close the doors? - Mean - 13.02.2011

No-Problemo