Array must be indexed..
#1

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.

pawn Код:
Sprunk++;
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!
Reply
#2

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

Hmm, thanks
Reply
#4

Or you can do like #define MAX_SPRUNK somevalue
Reply
#5

Solved i must remove the [MAX_SPRUNK] at new Sprunk = 0;
Reply
#6

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

And can i add/remove then values?
Reply
#8

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
pawn Код:
new Sprunk = 0;
except for arrays.
Reply
#9

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 }
Reply
#10

okay, i now that it can, but is it posible to add one in a script?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)