Moveobject trough a loop
#1

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
Reply
#2

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?
Reply
#3

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
Reply
#4

Okay so, did you try what I posted?
Reply
#5

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
Reply
#6

oke i edited my first post so watch the first post
Reply
#7

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.
Reply
#8

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
Reply
#9

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

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)