Functions

Hi there,
I am trying to write my own function that uses arrays to carry out the same function with different values. Before you ask everything is declared properly.

Here is my Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void Populate(int Amount, string TagArray, float xLoc, float yLoc, float zLoc, float Orient)
{
	int AutoInc = 0;
	
	while(AutoInc < Amount)
	{
              int a = AutoInc;              

		CreateObject(OBJECT_TYPE_CREATURE, TagArray[AutoInc], Location(Vector(xLoc[AutoInc], yLoc[AutoInc], zLoc[AutoInc]), Orient[AutoInc]);

		AssignCommand(TagArray[AutoInc],ActionRandomWalk());

		AutoInc++;
	}
}


The errors I get are:

1
2
Line 9 - Error: Syntax error at "["
Line 11 - Error: Syntax error at "["


It is clear that it is something to do with my arrays. Im just not sure what.

Any help would be appreciated.

TB12
Try this:

1
2
3
4
void Populate(int Amount, string TagArray, float xLoc[], float yLoc[], float zLoc[], float Orient[])
{
    //...
}

now i get the same error on the first line and also TagArray is also an array.

I also get a syntax error at while and CreateObject
Well... Try this:

1
2
3
4
void Populate(int Amount, string TagArray[], float xLoc[], float yLoc[], float zLoc[], float Orient[])
{
    //...
}

If you don't remember basic syntax stuff (e.g. how to pass arrays to functions), you can always take a look at your book or the tutorial of this site -> http://cplusplus.com/doc/tutorial/ If the problem is something this simple, you can most probably fix it on your own.
Topic archived. No new replies allowed.