How can i get an array to do this...
#1

Hi guys and girls

I need an array to create loads of pickups around the map (i have the x, y, z coords) - If i have the array, do i do this:

pawn Код:
CreatePickup(playerid, ModelID, Array[x], Array[y], Array[z]);
The model id will be the same for all, but the Create Pickup command will need to do it for all x.y.z coords.

How do i do this? - Ive done it before but i forgot how i did it lol

Thanks in advance
Ash!
Reply
#2

Id guess your array with the Coords is multi-dimensional, something like this:

new Float: pickups[][3]

Then you can create your pickups using a for-loop and using the counter as index for your array:

pawn Код:
for(new i = 0; i < sizeof(pickups); i ++) {
    CreatePickup(..., pickups[i][0], pickups[i][1], pickups[i][2]); //with 0,1,2 beeing x,y,z
}
Reply
#3

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
Id guess your array with the Coords is multi-dimensional, something like this:

new Float: pickups[][3]

Then you can create your pickups using a for-loop and using the counter as index for your array:

pawn Код:
for(new i = 0; i < sizeof(pickups); i ++) {
    CreatePickup(..., pickups[i][0], pickups[i][1], pickups[i][2]); //with 0,1,2 beeing x,y,z
}
Ahh, i knew it was something, thanks

Another thing, could i enum the array? So instead of 1, 2 and 3 being x, y, z i could actually call them x, y and z.

Like this:

pawn Код:
for(new i = 0; i < sizeof(pickups); i ++) {
    CreatePickup(..., pickups[i][x], pickups[i][y], pickups[i][z]);
}
Thanks
Ash
Reply
#4

pawn Код:
enum pData
{
    x,
    y,
    z
};

new Pickups[][pData];
Reply
#5

No problem, and yes, you can use an enum, that should work in the same way.
Reply
#6

Thanks - Hope i can return a favour
Reply
#7

Also needed this! thanks a lot : ))
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)