listitem name
#1

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.
Reply
#2

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.
Reply
#3

Push again after (nearly ) 24h.
Reply
#4

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)