SA-MP Forums Archive
Moveobject trough a loop - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Moveobject trough a loop (/showthread.php?tid=168328)



Moveobject trough a loop - DaneAMattie - 15.08.2010

Hello,

I want a loop that creates 50 objects and moves them all to a certain location so i tried:

new Object[50];

new Float:ACX;
new Float:ACY;
new Float:ACZ;
new Float:PACX;
new Float:PACY;
new Float:PACZ;
for(new ObjID = 0; ObjID < 50; ObjID++)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(gTeam[lalaid] == TEAM_ARMY)
{
if(gTeam[i] == TEAM_ARMY)
{
GetVehiclePos(VehicleNPC1,ACX,ACY,ACZ);
Object[ObjID] = CreateObject(354,ACX,ACY,ACZ,0,0,0);
GetPlayerPos(1,PACX,PACY,PACZ);
MoveObject(Object[ObjID],PACX,PACY,PACZ,59);
}
}
}
}
}

but the objects just seems to not move :S


Re: Moveobject trough a loop - Redgie - 15.08.2010

pawn Код:
for(new ObjID = 0; ObjID < 50; ObjID++)
{
    new Object = CreateObject(101,0,0,0,0,0,0);
    MoveObject(Object,10,10,0);
}
All your really doing though is creating 50 objects ontop of eachother?


Re: Moveobject trough a loop - DaneAMattie - 15.08.2010

Quote:
Originally Posted by Redgie
Посмотреть сообщение
pawn Код:
for(new ObjID = 0; ObjID < 50; ObjID++)
{
    new Object = CreateObject(101,0,0,0,0,0,0);
    MoveObject(Object,10,10,0);
}
All your really doing though is creating 50 objects ontop of eachother?
yea its just an example, they dont all come to the same place but in this example yes so your code wont realy help cuz your code make them all go to 1 spot :P


Re: Moveobject trough a loop - Redgie - 15.08.2010

Okay so, did you try what I posted?


Re: Moveobject trough a loop - DaneAMattie - 15.08.2010

Quote:
Originally Posted by Redgie
Посмотреть сообщение
Okay so, did you try what I posted?
no but i know what it will do, it will create 50 objects and move them all into 1 position, w8 ill change my example to some more clear, so check the first post now


Re: Moveobject trough a loop - DaneAMattie - 15.08.2010

oke i edited my first post so watch the first post


Re: Moveobject trough a loop - Redgie - 15.08.2010

Apply the code I gave you to that code, dot he work yourself. This forum is for help, so help yourself now that you've received help.


Re: Moveobject trough a loop - DaneAMattie - 15.08.2010

Quote:
Originally Posted by Redgie
Посмотреть сообщение
Apply the code I gave you to that code, dot he work yourself. This forum is for help, so help yourself now that you've received help.
yea but that code does not give all the object's its own ID, and i need that cuz after a time i have to remove m all


Re: Moveobject trough a loop - Tr1viUm - 15.08.2010

I think the 1 should be i instead....

pawn Код:
GetPlayerPos(1,PACX,PACY,PACZ);
pawn Код:
GetPlayerPos(i,PACX,PACY,PACZ);



Re: Moveobject trough a loop - DaneAMattie - 15.08.2010

Quote:
Originally Posted by Tr1viUm
Посмотреть сообщение
I think the 1 should be i instead....

pawn Код:
GetPlayerPos(1,PACX,PACY,PACZ);
pawn Код:
GetPlayerPos(i,PACX,PACY,PACZ);
thats not the prob, i tested it bcuz i was id 1 :P