Array must be indexed.. - 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: Array must be indexed.. (
/showthread.php?tid=277907)
Array must be indexed.. -
wouter0100 - 19.08.2011
hey,
I'am bussy with an include, but when i compile it give the following error:
Quote:
error 033: array must be indexed (variable "Sprunk")
|
pawn Код:
new Sprunk[MAX_SPRUNK] = 0;
New sprunk 0.
Add 1 to Sprunk.
pawn Код:
for(new i=0; i < Sprunk; i++){
Error line, the Sprunk must me indexed?
i hope somebody can help me.
thanks!
Re: Array must be indexed.. -
iPLEOMAX - 19.08.2011
It should look like:
pawn Код:
Sprunk[/*Sprunt ID here*/]++;
for(new i=0; i < MAX_SPRUNK; i++) {/* Things here */}
I suggest you read this:
Scripting Basics - Arrays
Re: Array must be indexed.. -
wouter0100 - 19.08.2011
Hmm, thanks
Re: Array must be indexed.. -
sleepysnowflake - 19.08.2011
Or you can do like #define MAX_SPRUNK somevalue
Re: Array must be indexed.. -
wouter0100 - 19.08.2011
Solved i must remove the [MAX_SPRUNK] at new Sprunk = 0;
Re: Array must be indexed.. -
Bakr - 19.08.2011
Just as a note, you can assign default values to arrays like so:
pawn Код:
new Sprunk[MAX_SPRUNK] = {0,...};
Which, in this specific case, you wouldn't need to do. Default variable values are 0 (or false if a Boolean).
Re: Array must be indexed.. -
wouter0100 - 19.08.2011
And can i add/remove then values?
Re: Array must be indexed.. -
Bakr - 19.08.2011
Yes, you can still do standard operations. That's just assigning each cell in the array with a specific value at creation. It's the same as doing
except for arrays.
Re: Array must be indexed.. -
wouter0100 - 19.08.2011
i have now:
pawn Код:
new Sprunk = 0,
Float: X[MAX_SPRUNK],
Float: Y[MAX_SPRUNK],
Float: Z[MAX_SPRUNK],
Can that smaller/simpler?
something like
pawn Код:
new Sprunk =
{ 1, X1, Y1, Z1 }
{ 2, X2, Y2, Z2 }
Re: Array must be indexed.. -
wouter0100 - 19.08.2011
okay, i now that it can, but is it posible to add one in a script?