SA-MP Forums Archive
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)
+--- Thread: Array must be indexed (/showthread.php?tid=305995)



Array must be indexed - zxc1 - 24.12.2011

pawn Код:
new Model;
new Color1;
new Color2;
new Price;
new Buyable;
pawn Код:
if(dialogid == 1)
    {
        if(response)
        {
            ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Car Factory","Choose the model of your vehicle:","Continue","");
            Model = inputtext;
        }
        if(!response)
        {
            SendClientMessage(playerid,-1,"{FF0000}.: Cancelled :.");
        }
    }
    if(dialogid == 2)
    {
        if(response)
        {
            ShowPlayerDialog(playerid,3,DIALOG_STYLE_INPUT,"Car Factory","Pickup the first color you wish:","Continue","");
            Color1 = inputtext;
        }
        if(!response)
        {
            SendClientMessage(playerid,-1,"{FF0000}.: Cancelled :.");
        }
    }
    if(dialogid == 3)
    {
        if(response)
        {
            ShowPlayerDialog(playerid,4,DIALOG_STYLE_INPUT,"Car Factory","Pickup the second color you wish:","Continue","");
            Color2 = inputtext;
        }
        if(!response)
        {
            SendClientMessage(playerid,-1,"{FF0000}.: Cancelled :.");
        }
    }
    if(dialogid == 4)
    {
        if(response)
        {
            ShowPlayerDialog(playerid,5,DIALOG_STYLE_INPUT,"Car Factory","How much will the car cost?","Continue","");
            Price = inputtext;
        }
        if(!response)
        {
            SendClientMessage(playerid,-1,"{FF0000}.: Cancelled :.");
        }
    }
    if(dialogid == 5)
    {
        if(response)
        {
            ShowPlayerDialog(playerid,6,DIALOG_STYLE_INPUT,"Car Factory","Will the car be buyable? (1 = Yes, 0 = No)","Continue","");
            Buyable = inputtext;
        }
        if(!response)
        {
            SendClientMessage(playerid,-1,"{FF0000}.: Cancelled :.");
        }
    }
Код:
error 006: must be assigned to an array
error 006: must be assigned to an array
error 006: must be assigned to an array
error 006: must be assigned to an array
error 006: must be assigned to an array



Respuesta: Array must be indexed - kirk - 24.12.2011

With that code you store a string inside an integer, a string of characters is a 1 dimension vector with a size "X" that holds the ammount of characters you input, which is also known as an array.

So if i did not missunderstand your code, it should be

new Model[SIZE];

and same with the rest, SIZE is a number, choose it yourself.


Re: Array must be indexed - zxc1 - 24.12.2011

I already tried that and I get this errors:
Код:
error 047: array sizes do not match, or destination array is too small
error 047: array sizes do not match, or destination array is too small
error 047: array sizes do not match, or destination array is too small
error 047: array sizes do not match, or destination array is too small
error 047: array sizes do not match, or destination array is too small
error 035: argument type mismatch (argument 1)
error 033: array must be indexed (variable "Model")
error 033: array must be indexed (variable "Color1")
error 033: array must be indexed (variable "Color2")
error 033: array must be indexed (variable "Price")
error 033: array must be indexed (variable "Buyable")



Re: Array must be indexed - zxc1 - 24.12.2011

BumP