Moving multiple objects at one time
#1

Hi guys,

I have a question about moving obejcts.

I want to move more then 1 object at the same time from point A to B and B to A.
I also wanted to do it with one timer.

My question:
How can I move multiple objects at 1 time? and back?

Do I have to do smthing like:
pawn Код:
Move1 = (CreateObject .....); //from A
Move1 = (CreateObject......); //From A

Move2 = (CreateObject .....); //To B
Move2 = (CreateObject......); //To B

Forward Move1
public OnGameModeInit()
{
    SetTimer("Move1", 1000, false); // Set a timer of 1000 miliseconds (1 second)
}

public Move1()
{
    MoveObject(Move1, 3.0, Move2)
}
Please tell me how I can do this.

Thanks!

Jer
Reply
#2

Here is what I do with my Area 51 gates script...

First create new variables(or something like that XD)...

Код:
new gate1;
new gate2;
Then create the objects...

Код:
gate1 = CreateObject(2927,215.92999390,1875.50000000,13.89999962,0.00000000,0.00000000,0.00000000); //object(a51_blastdoorr) (D)
gate2 = CreateObject(2929,211.85000732,1875.50000000,13.89999962,0.00000000,0.00000000,0.00000000); //object(a51_blastdoorl) (D)
Then make the command to open the gates(Can be done in other ways also)...

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/hopen", cmdtext, true, 6) == 0) 
	{
    		if(IsPlayerInRangeOfPoint(playerid, 5, 213.8570,1875.4865,13.1470))
    		{
			MoveObject(gate1, 219.92999390,1875.50000000,13.89999962, 1);// Opening the gate
			MoveObject(gate2, 207.85000732,1875.50000000,13.89999962, 1);// Opening the gate
			SetTimer("TimerName",5000,false); //5000 in milliseconds = 5 Seconds
    		}
		return 1;
	}
	return 0; //I put this return here because for some reason my code didn't want to work without it lol
}
Remember to make a forward for the timer and also a public function...
First the forward...

Код:
forward TimerName(playerid);
Then the public function...

Код:
public TimerName(playerid)
{
	MoveObject(gate1, 215.92999390,1875.50000000,13.89999962, 1);// Moving the gate
	MoveObject(gate2, 211.85000732,1875.50000000,13.89999962, 1);// Moving the gate
}
That should do it, hope I helped.
Reply
#3

Thanks for you reply, I tried this and it worked for a test but its hard to calculate all the times.

Now I have 1 object that is going to point B and is coming back to point A.

But its quite hard....


This is my test I made:
pawn Код:
forward objectgo();
forward objectback();
new Obj1;

public OnGameModeInit()
{
    Obj1 = CreateObject(8661, 2935.39990234, -1782.09997559, 10.69999981, 0.00000000, 0.00000000, 350.49682617);
    CreateDynamicObject(8661,2896.19995117, -1775.50000000, 10.69999981, 0.00000000, 0.00000000, 350.50000000);
    CreateDynamicObject(8661,3014.10009766, -1795.30004883, 10.69999981, 0.00000000, 0.00000000, 350.49682617);
    CreateDynamicObject(8661,3042.80004883, -1801.09997559, 10.69999981, 0.00000000, 0.00000000, 260.49679565);
   
    SetTimer("objectgo", 60000, true);
}
public objectgo()
{
    print("SERVER INFO: Object started moving to point B");
    SetTimer("objectback", 20000, false);
    MoveObject(Obj1, 2975.60009766,-1788.90002441,10.69999981, 2.5, 0.00000000,0.00000000,350.49682617);
}
public objectback()
{
    print("SERVER INFO: Object is going back to point A");
    MoveObject(Obj1, 2935.39990234, -1782.09997559, 10.69999981, 2.5, 0.00000000, 0.00000000, 350.49682617);
}
Reply
#4

Not sure what you mean, what do you want to reach exactly? What calculations do you need?
Reply
#5

look this is some test, I want to make a ferry, that transport people to an Island. So that ferry have to go there, and come back. on timers. So what I have to do:
-Start a timer that starts moving the object from A to B ( every minute, repeating)
- If the minute is done (then it start moving) and start another timer (20 secs) that will move the boat from B to A (not repeating)

So thats what I made above as test. Now I have to do it with moreobjects and longer distance : P
Reply
#6

First you need to set a timer to start moving the object from a-b like this maybe...

Код:
new testgate;

forward start(playerid);
public OnGameModeInit()//or public OnFilterscriptInit()
{
	testgate = CreateObject(3029,287.10000610,-29.5000,1000.5000,0.0000,0.0000,90.0000);
	SetTimer("start",2000,false);//Setting the timer to start moving the testgate to point b
	return 1;
}

forward test1(playerid);
public start(playerid)
{
	MoveObject(testgate, 1589.0000,-1638.2998,12.8000, 2);//Moving the testgate to point b
	SetTimer("test1",8000,false);//Object moves for eight seconds then executes the timer.
	return 1;
}

public test1(playerid)
{
	MoveObject(testgate, 1589.0000,-1638.2998,12.8000, 2);//Moving the testgate to point a
	SetTimer("test2",8000,false);//Object moves for eight seconds then executes the timer.
	return 1;
}

forward test2(playerid);
public start(playerid)
{
	MoveObject(testgate, 1589.0000,-1638.2998,12.8000, 2);//Moving the testgate to point b
	SetTimer("test1",8000,false);//Object moves for eight seconds then executes the timer.
	return 1;
}

public test2(playerid)
{
	MoveObject(testgate, 1589.0000,-1638.2998,12.8000, 2);//Moving the testgate to point a
	SetTimer("test1",8000,false);//Object moves for eight seconds then executes the timer.
	return 1;
}
Not sure if it will loop but I think so, also, i've just copied code from one of my scripts, so the objects, positions and timers should be set by you. Just determine the time it takes for the ferry to reach point b, then add the time you want the ferry to wait to that time.

I know it is 3 timers and you want one timer, but it is the best I can do ATM XD.

Hope I helped.
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)