SA-MP Forums Archive
Moving Objects Back To Where it Started Moving? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Moving Objects Back To Where it Started Moving? (/showthread.php?tid=332244)



Moving Objects Back To Where it Started Moving? - Elias_Haddad - 07.04.2012

Hey Guys I need To Ask A Question :
Is It Possible to move Object back to where it started moving?
pawn Код:
if(strcmp("/movef", cmdtext, true, 10) ==0)
                    {
                    MoveObject(objectid2,-1753.5853,885.3674,295.8750,19.00);
                    return 1;
                    }
If Yes Plz Tell Me How To Do It Using To Move Back The Object To Where It Was


Re: Moving Objects Back To Where it Started Moving? - Shabi RoxX - 07.04.2012

yes it is... Use again MoveObjects and use coords , i mean use orignal coords from create object... For this make another cmd or use timer.


Re: Moving Objects Back To Where it Started Moving? - Kindred - 07.04.2012

This is basic right here:

pawn Код:
if(strcmp("/movef", cmdtext, true, 10) ==0)
{
    if(gatename <= 0)
    {
        MoveObject(objectid2,-1753.5853,885.3674,295.8750,19.00);
    }
    else if(gatename >= 1)
    {
        MoveObject(objectid2,originalposx,originalposy,originalposz);
    }
    return 1;
}
First, you should create a global variable for the gate it is. So, as you see, if gatename is less then or equal to 0, it would move it to the cords you specified above. If it is greater then or equal to 1, it would move it back to the original position, which you must edit yourself, as you didn't show a createobject for the gate.

Notice, feel free to change it as you like, or, if you want two commands instead of making a global variable, just show me the first createobject for objectid2.

Or as the above poster said, you could probably make a timer too that would close after a certain amount of milliseconds has past.


Re: Moving Objects Back To Where it Started Moving? - park4bmx - 07.04.2012

yes just use MoveObject with the cordinates you created the object in first place!
example
pawn Код:
//needs to be at the top
new Gate1;//Its global
if(strcmp("/movef", cmdtext, true, 10) ==0)
    {
        if (Gate1==0){
                Gate1=1;
                MoveObject(objectid2,-1753.5853,885.3674,295.8750,19.00);
        }else{
                Gate1=0;
                MoveObject(objectid2,0,0,0,19.00);//the X,Y,Z of the original object pos
        }
        return 1;
    }



Re: Moving Objects Back To Where it Started Moving? - Elias_Haddad - 07.04.2012

pawn Код:
if(strcmp("/movef", cmdtext, true, 10) ==0)
                    {
                    MoveObject(objectid2,-1753.5853,885.3674,295.8750,19.00);
                    return 1;
                    } //this is the cmd
objectid2 = CreateObject(19338,2340.0117,-377.1778,757.0559,0.0,0.0,0.0,0.0); //the object
new objectid2; //on top of script
I want to make 2 cmd the first /movef to move the object to a location and the 2nd /moveb to move the object back to its original place


Re: Moving Objects Back To Where it Started Moving? - Kindred - 07.04.2012

pawn Код:
if(strcmp("/movef", cmdtext, true, 10) ==0)
{
    MoveObject(objectid2,-1753.5853,885.3674,295.8750,19.00);
    return 1;
}
if(strcmp("/moveb", cmdtext, true, 10) ==0)
{
    MoveObject(objectid2,2340.0117,-377.1778,757.0559,19.00);
    return 1;
}
That simple, just add the coords of the createobject into the new moveobject under the new command.


Re: Moving Objects Back To Where it Started Moving? - Elias_Haddad - 07.04.2012

Thx All For Replies It Helped Me Alot and thank you Kindred For the Code It Worked