error 008: must be a constant expression; assumed zero
#1

Hello,

I wanna undersand this error:

Quote:

error 008: must be a constant expression; assumed zero

pawn Код:
main()
{
    Add({3, 5, 2}, 3);
}

Add(arr[], size)
{
    for(new i; i < size; i++)
    {
        printf("%i", arr[i]);
    }
}
That's correct, so how use in my array a variable, because that pawn code, i've a error!

Код HTML:
error 008: must be a constant expression; assumed zero
pawn Код:
main()
{
    new playerone = 5, playertwo = 6;
    Add({playerone, playertwo}, 2);
}

Add(arr[], size)
{
    for(new i; i < size; i++)
    {
        printf("%i", arr[i]);
    }
}
How i can do?
Thanks
Reply
#2

It's too many arrays on Pawn the variable you're using must be declared Constant in order for it to be valid because the complier doesn't understand the value of the constant you're trying to use.
Reply
#3

The values are not constants. Declare an array and add values to it. For example:
pawn Код:
main()
{
    new
        arr[2];
   
    arr[0] = 5;
    arr[1] = 6;
   
    Add(arr, sizeof (arr));
}

Add(arr[], size)
{
    for(new i; i < size; i++)
    {
        printf("%i", arr[i]);
    }
}
Reply
#4

Ok! thanks but it's strange
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)