How can i make these 2 commands into 1?
#1

Hello, I want to make these 2 commands into one if that is possible?
pawn Код:
if (strcmp("/cellopen", cmdtext, true, 10) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(IsAPDMember(playerid) || IsAFreecop(playerid))
            {
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1491.21484375,-1764.90002441,3284.25048828)) //Cell0
                {
                    MoveDynamicObject(cell0,1491.21484375-1.25,-1764.90002441,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell0 has been opened.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1494.41210938,-1764.90002441,3284.25048828)) //Cell1
                {
                    MoveDynamicObject(cell1,1494.41210938-1.25,-1764.90002441,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell1 has been opened.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1497.61132812,-1764.90002441,3284.25048828)) //Cell2
                {
                    MoveDynamicObject(cell2,1497.61132812-1.25,-1764.90002441,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell2 has been opened.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1500.81445312,-1764.90002441,3284.25048828)) //Cell3
                {
                    MoveDynamicObject(cell3,1500.81445312-1.25,-1764.90002441,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell3 has been opened.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1500.81994629,-1761.51000977,3284.25048828)) //Cell4
                {
                    MoveDynamicObject(cell4,1500.81994629-1.25,-1761.51000977,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell4 has been opened.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1491.22094727,-1761.50000000,3284.25048828)) //Cell5
                {
                    MoveDynamicObject(cell5,1491.22094727-1.25,-1761.50000000,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell5 has been opened.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1494.41894531,-1761.51000977,3284.25048828)) //Cell6
                {
                    MoveDynamicObject(cell6,1494.41894531-1.25,-1761.51000977,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell6 has been opened.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1497.61999512,-1761.51000977,3284.25048828)) //Cell7
                {
                    MoveDynamicObject(cell7,1497.61999512-1.25,-1761.51000977,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell7 has been opened.");
                }
            }
        }
        return 1;
    }
and
pawn Код:
if (strcmp("/cellclose", cmdtext, true, 10) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(IsAPDMember(playerid) || IsAFreecop(playerid))
            {
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1491.21484375,-1764.90002441,3284.25048828)) //Cell0
                {
                    MoveDynamicObject(cell0,1491.21484375,-1764.90002441,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell0 has been closed.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1494.41210938,-1764.90002441,3284.25048828)) //Cell1
                {
                    MoveDynamicObject(cell1,1494.41210938,-1764.90002441,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell1 has been closed.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1497.61132812,-1764.90002441,3284.25048828)) //Cell2
                {
                    MoveDynamicObject(cell2,1497.61132812,-1764.90002441,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell2 has been closed.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1500.81445312,-1764.90002441,3284.25048828)) //Cell3
                {
                    MoveDynamicObject(cell3,1500.81445312,-1764.90002441,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell3 has been closed.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1500.81994629,-1761.51000977,3284.25048828)) //Cell4
                {
                    MoveDynamicObject(cell4,1500.81994629,-1761.51000977,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell4 has been closed.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1491.22094727,-1761.50000000,3284.25048828)) //Cell5
                {
                    MoveDynamicObject(cell5,1491.22094727,-1761.50000000,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell5 has been closed.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1494.41894531,-1761.51000977,3284.25048828)) //Cell6
                {
                    MoveDynamicObject(cell6,1494.41894531,-1761.51000977,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell6 has been closed.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1497.61999512,-1761.51000977,3284.25048828)) //Cell7
                {
                    MoveDynamicObject(cell7,1497.61999512,-1761.51000977,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell7 has been closed.");
                }
            }
        }
        return 1;
    }
Reply
#2

You'd want to create a variable.
Once you open the cell, that variable will turn to 1. And if it's one, and you use /cells (example command.) again, it will then move the objects back to the closed position.
Reply
#3

Create a variable like CellOpen, and when the cell opens with the command, CellOpen will set to 1,

and when you type it again If cellopen close the cell(too lazy to put exact code in)
Reply
#4

Like this right?
pawn Код:
if(!strcmp(cmdtext, "/opendoor", true)) // By CuervO_NegrO
    {
        if(IsACop(playerid) || PlayerInfo[playerid][pAdmin] >= 6 || IsAFreecop(playerid))
        {
            if(IsPlayerInRangeOfPoint(playerid, 4,251.2575,67.6536,1003.6406))
            {
                if(lspdw == 0)
                {
                    MoveDynamicObject(lspdwindows, 250.524,67.650,1001.08, 3.0000);
                    SendClientMessage(playerid, COLOR_BLUE,"SAPD Windows is Open, Please Close it!");
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    format(string, sizeof(string), "* %s takes his/her remote control and opens the Windows.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
                    lspdw = 1;
                }
                else
                {
                    MoveDynamicObject(lspdwindows, 250.524,67.650,1002.58, 3.0000);
                    SendClientMessage(playerid, COLOR_BLUE,"SAPD Windows is Closed, Thank You!");
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    format(string, sizeof(string), "* %s takes his/her remote control and closes the Windows.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
                    lspdw = 0;
                }
            }
        }
(this another command just to show if its like this you mean) I did this before but it just said that i had opened it but it didnt open
Reply
#5

Did you set it up like that command?
Unless im missing something it should work.
Reply
#6

Correct. Or instead of else I believe you could add
pawn Код:
if(cell == 1)
{
      //Move your object back to its closed state.
}
Reply
#7

https://sampforum.blast.hk/showthread.php?tid=278880
variable called bool = lifesaver i thought i show u different methods and ways
Reply
#8

Well maybe i did something wrong, I will try again and post my result in here
Reply
#9

lol i noticed now what i did wrong.. im so tired to i took the interior id where the gate id should be haha, I think i will go sleep now but thank you for the help anyway!
Reply
#10

maybe something like
Код:
COMMAND:cell(playerid, params[]) // if you are using strcmp change with the if(!strcmp(cmdtext, "/cell", true))
{
    if(!strcmp(params, "open", true))
    {
        if(IsPlayerConnected(playerid))
        {
            if(IsAPDMember(playerid) || IsAFreecop(playerid))
            {
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1491.21484375,-1764.90002441,3284.25048828)) //Cell0
                {
                    MoveDynamicObject(cell0,1491.21484375-1.25,-1764.90002441,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell0 has been opened.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1494.41210938,-1764.90002441,3284.25048828)) //Cell1
                {
                    MoveDynamicObject(cell1,1494.41210938-1.25,-1764.90002441,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell1 has been opened.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1497.61132812,-1764.90002441,3284.25048828)) //Cell2
                {
                    MoveDynamicObject(cell2,1497.61132812-1.25,-1764.90002441,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell2 has been opened.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1500.81445312,-1764.90002441,3284.25048828)) //Cell3
                {
                    MoveDynamicObject(cell3,1500.81445312-1.25,-1764.90002441,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell3 has been opened.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1500.81994629,-1761.51000977,3284.25048828)) //Cell4
                {
                    MoveDynamicObject(cell4,1500.81994629-1.25,-1761.51000977,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell4 has been opened.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1491.22094727,-1761.50000000,3284.25048828)) //Cell5
                {
                    MoveDynamicObject(cell5,1491.22094727-1.25,-1761.50000000,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell5 has been opened.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1494.41894531,-1761.51000977,3284.25048828)) //Cell6
                {
                    MoveDynamicObject(cell6,1494.41894531-1.25,-1761.51000977,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell6 has been opened.");
                }
                if(IsPlayerInRangeOfPoint(playerid, 2.0,1497.61999512,-1761.51000977,3284.25048828)) //Cell7
                {
                    MoveDynamicObject(cell7,1497.61999512-1.25,-1761.51000977,3284.25048828,0.50);
                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell7 has been opened.");
                }
            }
        }
    }
    else if(!strcmp(params, "close", true))
    {
	    if(IsPlayerConnected(playerid))
	        {
	            if(IsAPDMember(playerid) || IsAFreecop(playerid))
	            {
	                if(IsPlayerInRangeOfPoint(playerid, 2.0,1491.21484375,-1764.90002441,3284.25048828)) //Cell0
	                {
	                    MoveDynamicObject(cell0,1491.21484375,-1764.90002441,3284.25048828,0.50);
	                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell0 has been closed.");
	                }
	                if(IsPlayerInRangeOfPoint(playerid, 2.0,1494.41210938,-1764.90002441,3284.25048828)) //Cell1
	                {
	                    MoveDynamicObject(cell1,1494.41210938,-1764.90002441,3284.25048828,0.50);
	                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell1 has been closed.");
	                }
	                if(IsPlayerInRangeOfPoint(playerid, 2.0,1497.61132812,-1764.90002441,3284.25048828)) //Cell2
	                {
	                    MoveDynamicObject(cell2,1497.61132812,-1764.90002441,3284.25048828,0.50);
	                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell2 has been closed.");
	                }
	                if(IsPlayerInRangeOfPoint(playerid, 2.0,1500.81445312,-1764.90002441,3284.25048828)) //Cell3
	                {
	                    MoveDynamicObject(cell3,1500.81445312,-1764.90002441,3284.25048828,0.50);
	                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell3 has been closed.");
	                }
	                if(IsPlayerInRangeOfPoint(playerid, 2.0,1500.81994629,-1761.51000977,3284.25048828)) //Cell4
	                {
	                    MoveDynamicObject(cell4,1500.81994629,-1761.51000977,3284.25048828,0.50);
	                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell4 has been closed.");
	                }
	                if(IsPlayerInRangeOfPoint(playerid, 2.0,1491.22094727,-1761.50000000,3284.25048828)) //Cell5
	                {
	                    MoveDynamicObject(cell5,1491.22094727,-1761.50000000,3284.25048828,0.50);
	                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell5 has been closed.");
	                }
	                if(IsPlayerInRangeOfPoint(playerid, 2.0,1494.41894531,-1761.51000977,3284.25048828)) //Cell6
	                {
	                    MoveDynamicObject(cell6,1494.41894531,-1761.51000977,3284.25048828,0.50);
	                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell6 has been closed.");
	                }
	                if(IsPlayerInRangeOfPoint(playerid, 2.0,1497.61999512,-1761.51000977,3284.25048828)) //Cell7
	                {
	                    MoveDynamicObject(cell7,1497.61999512,-1761.51000977,3284.25048828,0.50);
	                    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Cell7 has been closed.");
	                }
	            }
	        }
	    }
	}
	return 1;
}
The commands will be

Код:
/cell open
/cell close
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)