Array size by MySQL rows number?
#1

Hello, I have a question. How can I make array size by mysql_num_rows? I doing this:
Код:
LoadSomethingToArray(playerid)
{
        mysql_query("SELECT * FROM table");
	mysql_store_result();
	new array[MAX_PLAYERS][mysql_num_rows()];
        for(new i=0; i<mysql_num_rows(); i++)
       {
                format(query, sizeof(query), "SELECT * FROM table WHERE ID=%i", i);
		mysql_query(query);
		mysql_retrieve_row();
		mysql_fetch_field_row(fetch, "SomeCol");
		array[playerid][i] = fetch;
		mysql_free_result();
       }
}
But in this situation I can't use array in any code position. I want to load all info in player login and use in all code.
Loaded info is string.
Reply
#2

Can't be done in Pawn. All array sizes must be known at compile time.
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Can't be done in Pawn. All array sizes must be known at compile time.
My code works properly, but I just can't use array in oter code locations.
Reply
#4

Pawn language doesn't work like php...
Read this tutorial : https://sampforum.blast.hk/showthread.php?tid=485633
Reply
#5

As Vince said, array size must be known at compile-time.
Creating the array inside the function would be pointless as well, because it will get deleted when you exit the function and taking the data with it.

Just make the array big enough to fit everything and put in outside functions.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)