SA-MP Forums Archive
error 008: must be a constant expression; assumed zero - 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)
+--- Thread: error 008: must be a constant expression; assumed zero (/showthread.php?tid=523951)



error 008: must be a constant expression; assumed zero - Noliax8 - 04.07.2014

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


Re: error 008: must be a constant expression; assumed zero - Wasim - 04.07.2014

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.


Re: error 008: must be a constant expression; assumed zero - Konstantinos - 04.07.2014

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]);
    }
}



Re: error 008: must be a constant expression; assumed zero - Noliax8 - 04.07.2014

Ok! thanks but it's strange