SA-MP Forums Archive
error 033: array must be indexed (variable "s") - 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 033: array must be indexed (variable "s") (/showthread.php?tid=663923)



error 033: array must be indexed (variable "s") - p3p4 - 14.02.2019

Quote:

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new updates = GetPVarInt(playerid, "UID");
if(dialogid == DIALOG_UPDATE)
{
if(response)
{
if(isnull(inputtext)) return ShowPlayerDialog(playerid, DIALOG_UPDATE, DIALOG_STYLE_INPUT, "adding update", "please write your update below", "Add", "Cancel");
for(new x=1 ; x<560 ; x++)
{
new s[256];
format(s, sizeof(s), "update%d", x);
if(!dini_Isset("updates.ini", s))
{
new year, month, day;
getdate(year, month, day);
new utext[1024];
format(utext, sizeof(utext), "%d/%d/%d", day, month, year);
format(s, sizeof(s), "date%d", x);
dini_Set("updates.ini", s, utext);
format(utext, sizeof(utext), "%s", inputtext);
format(s, sizeof(s), "update%d", x);
dini_Set("updates.ini", s, utext);
new dd = dini_Int("updates.ini", "MAX");
dini_IntSet("updates.ini", "MAX", dd+1);
format(s, sizeof(s), "Added update id %d. Your Update: '%s', and Date: %d/%d/%d.", x, inputtext, day, month, year);
SendClientMessage(playerid, COLOR_YELLOW, s);
break;
}
}
return 1;
}
return 1;

error is in this line :
Quote:

if(!dini_Isset("updates.ini", s))




Re: error 033: array must be indexed (variable "s") - TokicMajstor - 14.02.2019

Variable s is string so it must be indexed add [256] after that s like this:
Код:
if(!dini_Isset("updates.ini", s[256]))
By the way it's waste of cells 256 is too much


Re: error 033: array must be indexed (variable "s") - IllidanS4 - 15.02.2019

Quote:
Originally Posted by p3p4
Посмотреть сообщение
error is in this line :
Your code seems correct, must be some errorneous version of dini. Better don't use dini at all.

Quote:
Originally Posted by TokicMajstor
Посмотреть сообщение
Variable s is string so it must be indexed add [256] after that s like this:
Код:
if(!dini_Isset("updates.ini", s[256]))
By the way it's waste of cells 256 is too much
No, that would mean the cell starting at offset 256 from s[0], which is even beyond the variable.