SA-MP Forums Archive
Array object Move :P - 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: Array object Move :P (/showthread.php?tid=427248)



Array object Move :P - colonel-top - 31.03.2013

Its have a little question i cannot fix it so now i can create array but its not moving how to make it move all of array ?
pawn Code:
MoveObject(obj[177], 0, 0, -50, 2.00);
This my move object code i have obj[177] how i can move object all of array ?


Re: Array object Move :P - jessejanssen - 31.03.2013

If you mean you want to move all the objects created in ojb[x], do it like this:

pawn Code:
for(new i = 0; i < sizeof(obj); i++)
    {
    MoveObject(obj[i], 0, 0, -50, 2.00);
    }
And if you need different positions for the objects to move I recommend using a multidimensional array, like this:
pawn Code:
new objpos[x][3] = {
{0.00, 0.00, -50.00},
{0.00, 0.00, -40.00},
};

for(new i = 0; i < sizeof(obj); i++)
    {
    MoveObject(obj[i], objpos[i][0], objpos[i][1], objpos[i][2], 2.00);
    }
I hope you understand what I mean.

Best regards,
Jesse


Re: Array object Move :P - Babul - 31.03.2013

you need a loop to move each object.
btw, the MoveObject() positions are absolute, not relative - the destination coordinates need to be calculated for each single object before moving it:
pawn Code:
new Float:TargetX,Float:TargetY,Float:TargetZ;
for(new id=0;id<178;id++)
{
    GetObjectPos(obj[id],TargetX,TargetY,TargetZ);
    TargetZ=TargetZ-50.0;
    MoveObject(obj[id], TargetX, TargetY, TargetZ, 2.00);
}