mySQL loading houses (pretty close)
#3

Ok booked a lil bit more progress with the 2nd option:

OnGamemodeInIt:
Код:
//Loading houses from database
	new mysql_connection;
   	mysql_connection = mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
	mysql_query("SELECT * FROM `houses` WHERE `id` < "#MAX_HOUSES);
	mysql_store_result(mysql_connection);
	new n;
	while (mysql_retrieve_row())
	{
	    new tmp[32];
	    new id;
		GET_INT(id, "id");//Loads houseid
		GET_INT(Houses[id][House_Price], "price");
		GET_INT(Houses[id][House_Interior], "interior");
		GET_STR(Houses[id][HouseOwner], "owner");

		new Float:x, Float:y, Float:z;
		GET_FLOAT(x, "x");
		GET_FLOAT(y, "y");
		GET_FLOAT(z, "z");
		Houses[id][hX] = x;
		Houses[id][hY] = y;
		Houses[id][hZ] = z;
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
			HouseCPOut[i] = CreateDynamicCP(x, y, z, 1.5, 0, 0, -1, 5.0);
		}
        SpawnHouse();
	    n++;
	}
That actually works and creates a checkpoint.
But I want to know why it works like that, and not like this:
Код:
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
			HouseCPOut[i] = CreateDynamicCPHouses[id][hX],Houses[id][hY],Houses[id][hZ], 1.5, 0, 0, -1, 5.0);
		}
Is there something wrong? Or is it right and could it be that somehow the enum isn't right?

also could somebody give me a little bit explanation at things like:
Код:
for(new i = 0; i < MAX_PLAYERS; i++)
which I believe is the same as Loop(i, MAX_PLAYERS) with this on the top of my script:
Код:
#define Loop(%0,%1) for(new %0 = 0; %0 < %1; %0++)
and why sometimes this doesn't work:
Код:
for(new i = 0; i < MAX_PLAYERS; i++)
And this does:
Код:
new i; for(i = 0; i < MAX_PLAYERS; i++)
Reply


Messages In This Thread
mySQL loading houses problem. Please help!? - by jesse237 - 29.08.2011, 15:46
RE: mySQL loading houses problem. Please help!? - by jesse237 - 31.08.2011, 13:49
Re: mySQL loading houses (pretty close) - by jesse237 - 31.08.2011, 16:50
Re: mySQL loading houses (pretty close) - by PrawkC - 31.08.2011, 18:40
Re: mySQL loading houses (pretty close) - by jesse237 - 01.09.2011, 16:07

Forum Jump:


Users browsing this thread: 1 Guest(s)