Script stops execution when trying to declare an array
#1

Hi there, today I encountered something which I consider to be just plain stupid, and that is, when trying to declare an array like arrPlayer[ x ][ x ].

Well, the thing is, if I declare it like arrPlayer[3][ x ] it works out just fine, but, if I declare more than 3, like arrPlayer[96][ x ], it simply stops the execution while trying to declare it.

Here is a bit of my code so you guys can see clearly what I'm talking about:

Код:
format(query, sizeof(query), "SELECT * FROM characters WHERE id = %d LIMIT 1", UserInfo[playerid][uChar]);
		printf("OnPlayerLogin(Get Char): %s", query);
		mysql_query(query);
		mysql_store_result();
		if (mysql_fetch_row_format(resultline, "|"))
		{
		  new arrPlayer[96][256];
			split(resultline, arrPlayer, '|');
			printf("%d", sizeof(arrPlayer));
			
			CharInfo[playerid][pID] = strval(arrPlayer[0]);
			CharInfo[playerid][pUserID] = strval(arrPlayer[1]);
And so on...
And it only prints out the first printf: [05:43:30] OnPlayerLogin(Get Char): SELECT * FROM characters WHERE id = 1 LIMIT 1

It does indeed fetch the formatted row and all but it just stops when declaring that array.

What can I be missing here?

Thanks in advance.
Reply
#2

strval crashes the execution if the string is above 50 characters. Maybe that's your problem?

Edit: Actually no, if it doesn't print the first one, it wouldn't be that, sorry.

Edit: Maybe you cannot print the strlen of a string before it has been formatted?
Reply
#3

Even if I just declare the array and don't use it on something, it will cause the same result.

I can't really think if something that might be causing this.
Reply
#4

Does the query actually return something? Is there a field in the table characters with id 1?
Reply
#5

Like I said in the first post it does fetch the data I want to, because I already had a print returning the resultline and It is okay.
Reply
#6

Well I've managed to fix it just by declaring it at the top of my script.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)