SA-MP Forums Archive
listitem name - 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: listitem name (/showthread.php?tid=569200)



listitem name - yellow - 28.03.2015

Hey,

why doesn't this work?
Код:
enum l_data{//listitem
	listname[MAX_FRAK_LEN],
	bool:used = false
}

new list[MAX_LIST][l_data];
//..
for(new i = 0;i < Fraks; i++)
	{
		format(string,sizeof(string),"%s%s | "#HEXBlue"%s\n",string, fraktion[i][f_name], fraktion[i][f_leader]);
		format(list[i][listname], MAX_FRAK_LEN, fraktion[i][f_name]);
		list[i][used] = true;
                printf("%s",list[i][listname]); // -> Output is okay.
	}
	

//.. OnDialogResponse
new len = CountActiveList() - 1;
			printf("%d", len);
			new string[200];
			printf("%d",listitem);
			if(listitem <= len) 
			{
				printf("%s",list[listitem][listname]); // Output is wrong. Just random chars
				var[playerid][sList] = listitem;
				
			}
			else if(listitem == (len + 1))
			{
			   	printf("%d | %d", listitem, len);
			    print("add");
			}
			
			else if(listitem >= (len + 2))
			{
			    printf("%d | %d", listitem, len);
			    print("Delete");
			}

stock CountActiveList()
{
	new count;
	new i = 0;
	for(;i < MAX_LIST; i++ )
	{
	    if(list[i][used] == false)continue;
	    count ++;
	}
	return count;
}
Seems like something is wrong with the listitem.


AW: listitem name - yellow - 29.03.2015

Push after 24h.
I could do sth like
Код:
new index = strfind(inputtext,"|",false );
				strdel(inputtext,index-1 , strlen(inputtext));
But that's not the best solution.


AW: listitem name - yellow - 30.03.2015

Push again after (nearly ) 24h.


AW: listitem name - Kaliber - 30.03.2015

Quote:

enum l_data{//listitem
listname[MAX_FRAK_LEN],
bool:used = false
}

This is a cruel mistake, write it like this:

Код:
enum l_data{//listitem
	listname[MAX_FRAK_LEN],
	bool:used
}
You should read a tutorial about enums