MoveObject Error
#1

Hey guys, I made a command (/door) to open/close doors, however, when I do /door next to the object, the door opens however when I do /door again, it doesn't close :[

Anyone know how to fix this? Here is the command:
Код:
CMD:door(playerid,params[])
{
    if(IsLaw(playerid))
    {
		if(IsPlayerInRangeOfPoint(playerid, 2.0,1487.00000000,-1762.42504883,3284.23608398))
		{
	 		MoveObject(door0,1487.00000000,-1762.42504883+1.25,3284.23608398,0.50);
		}
		else if(IsPlayerInRangeOfPoint(playerid, 2.0,1487.00000000,-1762.42504883,3284.23608398))
		{
	 		MoveObject(door0,1487.00000000,-1762.42504883,3284.23608398,0.50);
		}
		if(IsPlayerInRangeOfPoint(playerid, 2.0, 1483.79003906,-1762.42504883,3284.23608398))
		{
	 		MoveObject(door1,1483.79003906,-1762.42504883+1.25,3284.23608398,0.50);
		}
		else if(IsPlayerInRangeOfPoint(playerid, 2.0, 1483.79003906,-1762.42504883,3284.23608398))
		{
	 		MoveObject(door1,1483.79003906,-1762.42504883,3284.23608398,0.50);
		}
		if(IsPlayerInRangeOfPoint(playerid, 2.0, 1479.85998535,-1758.31994629,3284.23388672))
		{
	 		MoveObject(door2,1479.85998535-1.25,-1758.31994629,3284.23388672,0.50);
		}
		else if(IsPlayerInRangeOfPoint(playerid, 2.0, 1479.85998535,-1758.31994629,3284.23388672)) //Door 2
		{
	 		MoveObject(door2,1479.85998535,-1758.31994629,3284.23388672,0.50);
		}
		if(IsPlayerInRangeOfPoint(playerid, 2.0, 1467.06701660,-1758.31994629,3284.23388672))
		{
	 		MoveObject(door3,1467.06701660-1.25,-1758.31994629,3284.23388672,0.50);
		}
		else if(IsPlayerInRangeOfPoint(playerid, 2.0, 1467.06701660,-1758.31994629,3284.23388672))
		{
	 		MoveObject(door3,1467.06701660,-1758.31994629,3284.23388672,0.50);
		}
	}
	return 1;
}
Reply
#2

try this:
PHP код:
CMD:door(playerid,params[])
{
    if(
IsLaw(playerid))
    {
        if(
IsPlayerInRangeOfPoint(playerid2.0,1487.00000000,-1762.42504883,3284.23608398))
        {
             
MoveObject(door0,1487.00000000,-1762.42504883+1.25,3284.23608398,0.50);
        }
        else if(
IsPlayerInRangeOfPoint(playerid2.0,1487.00000000,-1762.42504883,3284.23608398))
        {
             
MoveObject(door0,1487.00000000,-1762.42504883,3284.23608398,0.50);
        }
        else if(
IsPlayerInRangeOfPoint(playerid2.01483.79003906,-1762.42504883,3284.23608398))
        {
             
MoveObject(door1,1483.79003906,-1762.42504883+1.25,3284.23608398,0.50);
        }
        else if(
IsPlayerInRangeOfPoint(playerid2.01483.79003906,-1762.42504883,3284.23608398))
        {
             
MoveObject(door1,1483.79003906,-1762.42504883,3284.23608398,0.50);
        }
        else if(
IsPlayerInRangeOfPoint(playerid2.01479.85998535,-1758.31994629,3284.23388672))
        {
             
MoveObject(door2,1479.85998535-1.25,-1758.31994629,3284.23388672,0.50);
        }
        else if(
IsPlayerInRangeOfPoint(playerid2.01479.85998535,-1758.31994629,3284.23388672)) //Door 2
        
{
             
MoveObject(door2,1479.85998535,-1758.31994629,3284.23388672,0.50);
        }
        else if(
IsPlayerInRangeOfPoint(playerid2.01467.06701660,-1758.31994629,3284.23388672))
        {
             
MoveObject(door3,1467.06701660-1.25,-1758.31994629,3284.23388672,0.50);
        }
        else if(
IsPlayerInRangeOfPoint(playerid2.01467.06701660,-1758.31994629,3284.23388672))
        {
             
MoveObject(door3,1467.06701660,-1758.31994629,3284.23388672,0.50);
         }
       }
    return 
1;

Reply
#3

Still doesn't work
Reply
#4

Anyone?
Reply
#5

Quote:
Originally Posted by Jigsaw123
Посмотреть сообщение
Still doesn't work
You do not cut command arguments to use them! "/door open" and "/door close".
Therefore:

1. Go to where you door
2. Enter command "/door" NOT "/door open"
3. Miracle happened
Reply
#6

What has that to do with this? I didn't put /door open or /door close, I just put /door, didn't you see the codes? ^^
Reply
#7

Quote:
Originally Posted by Jigsaw123
Посмотреть сообщение
What has that to do with this? I didn't put /door open or /door close, I just put /door, didn't you see the codes? ^^
So you have positioned the doors near.
Another reason why you can not see does not work
Reply
#8

This is confirmed by your position, even doors. Why are they the same?

// CODE
if(IsPlayerInRangeOfPoint(playerid, 2.0,1487.00000000,-1762.42504883,3284.23608398))
{
MoveObject(door0,1487.00000000,-1762.42504883+1.25,3284.23608398,0.50);
}
else if(IsPlayerInRangeOfPoint(playerid, 2.0,1487.00000000,-1762.42504883,3284.23608398))
{
MoveObject(door0,1487.00000000,-1762.42504883,3284.23608398,0.50);
}
// EOF

NOTE: You need to change the position of the coordinates to IsPlayerInRangeOfPoint() does not always work on #1 door.
Reply
#9

Or you can write code like this:
PHP код:
#define  MAX_DOORS (4)
CMD:door(playerid,params[])
{
   
    if(
IsLaw(playerid))
    {
        static 
            
bool:door_state[MAX_DOORS]
        ;
        
// Door #1
        
if(IsPlayerInRangeOfPoint(playerid2.0,1487.00000000,-1762.42504883,3284.23608398))
        {
            if (!
door_state[0]) {
                
MoveObject(door0,1487.00000000,-1762.42504883+1.25,3284.23608398,0.50); 
                
door_state[0] = true;
            } else {
                
MoveObject(door0,1487.00000000,-1762.42504883,3284.23608398,0.50); 
                
door_state[0] = false;
            }
        }
        
// Door #2
        // Etc... (Do the same with the other doors)
    
}
    return 
1;

Reply
#10

hope this one work:
PHP код:
CMD:door(playerid,params[])
{
    if(
IsLaw(playerid))
    {
        if(
IsPlayerInRangeOfPoint(playerid2.0,1487.00000000,-1762.42504883,3284.23608398))
        {
             
MoveObject(door0,1487.00000000,-1762.42504883+1.25,3284.23608398,0.50);
        }
        else if(
IsPlayerInRangeOfPoint(playerid2.0,1487.00000000,-1763.67504883,3284.23608398))
        {
             
MoveObject(door0,2.0,1487.00000000,-1762.42504883,3284.23608398,0.50);
        }
        else if(
IsPlayerInRangeOfPoint(playerid2.01483.79003906,-1762.42504883,3284.23608398))
        {
             
MoveObject(door1,1483.79003906,-1762.42504883+1.25,3284.23608398,0.50);
        }
        else if(
IsPlayerInRangeOfPoint(playerid2.01483.79003906,-1762.42504883+1.25,3284.23608398))
        {
             
MoveObject(door1,1483.79003906,-1762.42504883,3284.23608398,0.50);
        }
        else if(
IsPlayerInRangeOfPoint(playerid2.01479.85998535,-1758.31994629,3284.23388672))
        {
             
MoveObject(door2,1479.85998535-1.25,-1758.31994629,3284.23388672,0.50);
        }
        else if(
IsPlayerInRangeOfPoint(playerid2.01479.85998535-1.25,-1758.31994629,3284.23388672)) //Door 2
        
{
             
MoveObject(door2,1479.85998535,-1758.31994629,3284.23388672,0.50);
        }
        else if(
IsPlayerInRangeOfPoint(playerid2.01467.06701660,-1758.31994629,3284.23388672))
        {
             
MoveObject(door3,1467.06701660-1.25,-1758.31994629,3284.23388672,0.50);
        }
        else if(
IsPlayerInRangeOfPoint(playerid2.01467.06701660-1.25,-1758.31994629,3284.23388672))
        {
             
MoveObject(door3,1467.06701660,-1758.31994629,3284.23388672,0.50);
         }
       }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)