SA-MP Forums Archive
Need help with a Gate. - 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)
+--- Thread: Need help with a Gate. (/showthread.php?tid=320186)



Need help with a Gate. - rangerxxll - 21.02.2012

Hi,
I'm planning on making a gate open (It'll open going into the ground) with one command. I've scripted most of it, but everytime I test it in-game the gate moves South, and it never stops. I just want it to go into the ground when I do the command /gate and go back up when I do the command /gate.

What's wrong with the code?
pawn Код:
new Gate, bool:GateClosed = true;
Gate = CreateObject(971, 1620.69995117, -1882.40002441, 15.30000019, 0.00000000, 0.00000000, 179.99993896, 100.0); // Gate closed


CMD:gate(playerid, params[])
{
    if(GateClosed){
        if(IsPlayerInRangeOfPoint(playerid, 15.0, 1620.69995117, -1882.40002441, 15.30000019)){
            GateClosed = false;
            MoveObject(Gate, 1620.69995117, 69995117, -1882.40002441, 3.0, 0.00000000, 0.00000000, 179.99993896);
            return 1;
        }
    }
    else{
        if(IsPlayerInRangeOfPoint(playerid, 15.0, 1620.69995117, -1882.40002441, 15.30000019)){
            GateClosed = true;
            MoveObject(Gate, 1620.69995117, -1882.40002441, 15.30000019, 3.0, 0.0, 0.0, 179.99993896);
           
        }
    }   return 1;
}
Thanks for your help.


Re: Need help with a Gate. - ReneG - 21.02.2012

Make sure the actual gate is under OnGameModeInit().
you are not filling your if statement correctly. You are basically saying
Код:
If GateClosed the move this gate.
You need to add a return value on the if statement.

So like this.

pawn Код:
CMD:gate(playerid, params[])
{
    if(GateClosed == true){
        if(IsPlayerInRangeOfPoint(playerid, 15.0, 1620.69995117, -1882.40002441, 15.30000019)){
            GateClosed = false;
            MoveObject(Gate, 1620.69995117, 69995117, -1882.40002441, 3.0, 0.00000000, 0.00000000, 179.99993896);
            return 1;
        }
    }
    else
    {
        if(GateClosed == false)
        {
            if(IsPlayerInRangeOfPoint(playerid, 15.0, 1620.69995117, -1882.40002441, 15.30000019)){
            GateClosed = true;
            MoveObject(Gate, 1620.69995117, -1882.40002441, 15.30000019, 3.0, 0.0, 0.0, 179.99993896);
            return 1;
        }
    }
    return 1;
}



Re: Need help with a Gate. - rangerxxll - 21.02.2012

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
Make sure the actual gate is under OnGameModeInit().
you are not filling your if statement correctly. You are basically saying
Код:
If GateClosed the move this gate.
You need to add a return value on the if statement.

So like this.

pawn Код:
CMD:gate(playerid, params[])
{
    if(GateClosed == true){
        if(IsPlayerInRangeOfPoint(playerid, 15.0, 1620.69995117, -1882.40002441, 15.30000019)){
            GateClosed = false;
            MoveObject(Gate, 1620.69995117, 69995117, -1882.40002441, 3.0, 0.00000000, 0.00000000, 179.99993896);
            return 1;
        }
    }
    else
    {
        if(GateClosed == false)
        {
            if(IsPlayerInRangeOfPoint(playerid, 15.0, 1620.69995117, -1882.40002441, 15.30000019)){
            GateClosed = true;
            MoveObject(Gate, 1620.69995117, -1882.40002441, 15.30000019, 3.0, 0.0, 0.0, 179.99993896);
            return 1;
        }
    }
    return 1;
}
Thanks. But when I do /gate to open it, the gate continues to go south and not under the ground. But when I do /gate to close it, it goes back to the correct position. Am I doing anything else wrong? Xd


Re: Need help with a Gate. - ReneG - 21.02.2012

If it is involved with moving then your MoveObject coordinates are wrong :P


Re: Need help with a Gate. - rangerxxll - 21.02.2012

What coordinate would make it go south? >.<


Re: Need help with a Gate. - JhnzRep - 21.02.2012

By south do you mean up and down? o.O


Re: Need help with a Gate. - rangerxxll - 21.02.2012

Quote:
Originally Posted by JhnzRep
Посмотреть сообщение
By south do you mean up and down? o.O
Er, yea.


Re: Need help with a Gate. - JhnzRep - 21.02.2012

That would be the Z coordinate.


Re: Need help with a Gate. - rangerxxll - 22.02.2012

Well, my Z coordinate is currently -1882.40002441. Does it look wrong, or?...


Re: Need help with a Gate. - JhnzRep - 22.02.2012

Uhh, don't know.