[ZCMD]Gate problem - Will open but not close
#1

Alright, i'm making an LSPD gate near the garage. When i type /gate, the thing moves ups. I then type /gate again, and it says "The gate is now closing" but it stays up. Not sure why it isn't working, here is the script:

((Using ZCMD))
pawn Код:
// Top of script:

new Gateopen;
new LSPDGate;

// OnGameModeInit:
LSPDGate = CreateObject(968, 1544.6600341797, -1623.9599609375, 13.10000038147, 0, 270, 90); //Creating the object

//Somewhere at the bottom of the script
CMD:gate(playerid, params[])
{
    if(Gateopen == 0)
    {
        if(IsPlayerInRangeOfPoint(playerid, 7.0, 1544.6600341797, -1623.9599609375, 13.10000038147))
        {
            MoveObject(LSPDGate, 1544.6591796875, -1623.9599609375, 13.10000038147, 5);
            SendClientMessage(playerid, 0xEF994300, "The gate is opening!");
            Gateopen = 1;
        }
        else
        {
            SendClientMessage(playerid, 0xEF994300, "You are not in range of a gate!");
        }
    }
    else if(Gateopen == 1)
    {
        if(IsPlayerInRangeOfPoint(playerid, 7.0, 1544.6591796875, -1623.9599609375, 13.10000038147))
        {
            MoveObject(LSPDGate,  1544.6600341797, -1623.9599609375, 13.10000038147, 5);
            SendClientMessage(playerid, 0xEF994300, "The gate is closing!");
            Gateopen = 0;
        }
        else
        {
            SendClientMessage(playerid, 0xEF994300, "You are not in range of a gate!");
        }
    }
    return 1;
}
Tip: The gate moves when i type /gate first, like, it says "The gate is opening", which means that inside the brackets worked and it moves the gate. But when i do it again, it checks if it is open, and it does, then it says "The gate is closing!" and it stays up, it doesn't move.

This is probably just an easy fix.

PS: I'm a newbie in Pawn.
Reply
#2

Change coordinates in else if(Gateopen == 1)
Coordinates are same as in if(Gateopen == 0)
Reply
#3

I'm using barrierturn on MTA. It is an orange barrier. When i type /gate, it opens the gate correctly. But when i type it again, it won't go back down. As you will notice, they are not the same.
Код:
Gateopen = 0 MoveObject(LSPDGate, 1544.6591796875, -1623.9599609375, 13.10000038147, 5);
Gateopen = 1 MoveObject(LSPDGate, 1544.6600341797, -1623.9599609375, 13.10000038147, 5);
If you can see correctly, they are different. There X value is changed slightly. In number 1, you notice in MoveObject i set the object back to its original position (as you can see under OnGameModeInit.

Please, someone help me.
Reply
#4

Yeah, i see changes in 0.001 LoL
Move of 0.001 is nothing, you can't see it...
If you want to move object up and down you need to change Z (third) coordinate...
Reply
#5

Quote:
Originally Posted by KurtBag
Посмотреть сообщение
I'm using barrierturn on MTA. It is an orange barrier. When i type /gate, it opens the gate correctly. But when i type it again, it won't go back down. As you will notice, they are not the same.
Код:
Gateopen = 0 MoveObject(LSPDGate, 1544.6591796875, -1623.9599609375, 13.10000038147, 5);
Gateopen = 1 MoveObject(LSPDGate, 1544.6600341797, -1623.9599609375, 13.10000038147, 5);
If you can see correctly, they are different. There X value is changed slightly. In number 1, you notice in MoveObject i set the object back to its original position (as you can see under OnGameModeInit.

Please, someone help me.
I laughed so hard at this! If you have ever done graphs in school or something, you would of remembered that the X and Y positions work both horizontally and vertically. If you want the gate to move South, you would subtract from the X, if you wanted it to go North, you would add to it. If you wanted it to go East, you would add to the Y, West would be subtracted... etc. Although it doesn't use a Z co-ordinate right? Because normal graphs aren't 3d, so the Z co-ord is used to measure it's height, just like in 3D objects... If you want the gate to go up, add to the Z co-ord... if you want it to go down... subtract from it... MoveObject(LSPDGate, X, Y, Z, 5...)

P.S. You need to add 0, 270, 90 on the end of each MoveObject function....
so:

pawn Код:
Gateopen = 0 MoveObject(LSPDGate, 1544.6591796875, -1623.9599609375, 13.10000038147, 5, 0, 270, 90);
Gateopen = 1 MoveObject(LSPDGate, 1544.6600341797, -1623.9599609375, 13.10000038147, 5, 0, 270, 90);
IF, you are using SA-MP 0.3d... otherwise leave it the same.

EDIT: He's right btw... your closed gate co-ordinate, should be the same co-ordinates as your CreateObject position...
Reply
#6

I added 0, 270, 90 to the end, and added the updates for the includes and now when i do /gate it neither opens / closes, although it still says "You have opened the gate" or "You have closed the gate"
Reply
#7

Are you running a 0.3d version?
Reply
#8

Yes, i am.

If i wasn't, it would't compile either if i remember correctly.
Reply
#9

BUMP,

I really need to fix this, i am using 0.3d.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)