How do I make something open and close with one command?
#1

pawn Код:
if(!strcmp(cmdtext, "/open", true))
        {
            if(IsPlayerInRangeOfPoint(playerid, 10, 1410.19995117, -1650.09997559, 13.80000019))
        {
                MoveObject(GateOpen, 1410.09997559, -1650.09997559, 10.80000019, 3);
                SendClientMessage(playerid, 0xEF994300, "You have opened the gate.");
        }
            if(IsPlayerInRangeOfPoint(playerid, 10, 955.70001221,-50.70000076,1002.00000000))
        {
                MoveObject(Door, 955.70001221,-50.59999847,998.20001221, 3);
        }
            return 1;
        }
       
    if(!strcmp(cmdtext, "/close", true))
        {
            if(IsPlayerInRangeOfPoint(playerid, 10, 1410.19995117,-1650.09997559,13.80000019))
        {
                MoveObject(GateOpen, 1410.19995117, -1650.09997559, 13.80000019, 3);
                SendClientMessage(playerid, 0xEF994300, "You have closed the gate.");
        }
            if(IsPlayerInRangeOfPoint(playerid, 10, 955.40002441,-49.90000153,1000.09997559))
        {
                MoveObject(Door, 955.70001221,-50.70000076,1002.00000000, 3);
        }
            return 1;
        }
I have this at the moment, but I want it so that one command "/" can open and close the door/gate in question. Help please.
Reply
#2

Not tested
pawn Код:
if(!strcmp(cmdtext, "/open", true))
    {
        if(IsPlayerInRangeOfPoint(playerid, 10, 1410.19995117, -1650.09997559, 13.80000019))
        {
            MoveObject(GateOpen, 1410.09997559, -1650.09997559, 10.80000019, 3);
            SendClientMessage(playerid, 0xEF994300, "You have opened the gate.");
        }
        if(IsPlayerInRangeOfPoint(playerid, 10, 955.70001221,-50.70000076,1002.00000000))
        {
            MoveObject(Door, 955.70001221,-50.59999847,998.20001221, 3);
        }
        else
        {
        if(IsPlayerInRangeOfPoint(playerid, 10, 1410.19995117,-1650.09997559,13.80000019))
        {
            MoveObject(GateOpen, 1410.19995117, -1650.09997559, 13.80000019, 3);
            SendClientMessage(playerid, 0xEF994300, "You have closed the gate.");
        }
        if(IsPlayerInRangeOfPoint(playerid, 10, 955.40002441,-49.90000153,1000.09997559))
        {
                MoveObject(Door, 955.70001221,-50.70000076,1002.00000000, 3);
        }}
        return 1;}
Reply
#3

Make a GLOBAL variable, like
pawn Код:
new DoorStatus;
then change the command to check if this global variable equals to 1(door open) or 0 (door closed)
then just set the 1 and 0 to this one command, if you don't get it, I can do it for you.
pawn Код:
public OnGameModeInit()
{
     DoorStatus = 0;    
     return 1;
}
pawn Код:
if(!strcmp(cmdtext, "/door", true))
        {
            if(DoorStatus == 0) // checks if it is CLOSED
            if(IsPlayerInRangeOfPoint(playerid, 10, 1410.19995117, -1650.09997559, 13.80000019))
        {
                MoveObject(GateOpen, 1410.09997559, -1650.09997559, 10.80000019, 3);
                SendClientMessage(playerid, 0xEF994300, "You have opened the gate.");
        }
            if(IsPlayerInRangeOfPoint(playerid, 10, 955.70001221,-50.70000076,1002.00000000))
        {
                MoveObject(Door, 955.70001221,-50.59999847,998.20001221, 3);
        }
             else if(DoorStatus == 1) // checks if the door is OPEN
            {
                  // close it here.
            }
             return 1;
        }
You'll get the idea
Reply
#4

You could always make it open and close on a timer?
Reply
#5

pawn Код:
if(!strcmp(cmdtext, "/", true))
        {
            if(GateOpenStatus == 0)
            if(IsPlayerInRangeOfPoint(playerid, 10, 1410.19995117, -1650.09997559, 13.80000019))
        {
                MoveObject(GateOpen, 1410.09997559, -1650.09997559, 10.80000019, 3);
                SendClientMessage(playerid, 0xEF994300, "You have opened the gate.");
        }
                    else if(GateOpenStatus == 1)
        {
                MoveObject(GateOpen, 1410.19995117, -1650.09997559, 13.80000019, 3);
                SendClientMessage(playerid, 0xEF994300, "You have closed the gate.");
        }
            if(DoorStatus == 0)
            if(IsPlayerInRangeOfPoint(playerid, 10, 955.70001221,-50.70000076,1002.00000000))
        {
                MoveObject(Door, 955.70001221,-50.59999847,998.20001221, 3);
        }
                else if(DoorStatus == 1)
        {
                MoveObject(Door, 955.70001221,-50.70000076,1002.00000000, 3);
        }
            return 1;
        }
How do I make it so that when I open the door, it changes the Door/GateOpenStatus to 1?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)