Simple question - can dini be mixed with sql?
#1

As tittle says, can dini be mixed with sql on the same gamemode? I cant get stock LoadBlabla to work and currently im out of ideas of what could be causing that. When i manually create a command to call the sql query, its working, but if i automatically make it call when the server starts, it doesnt. Ive tryed it on a script, that has no dini and it was working fine.
Reply
#2

No, it wouldn't mix them if you use SQL for a use and Dini for another use (I mean: not both for the same thing).

So let me understand, the one you have problems is the SQL? Would you mind to post few details about your problem so we'll be able to help you?
Reply
#3

Alright, ill try to explain as understandable as i can.
I have created 3dtextdraws which are showing values from sql database.
Код:
format(string, 60, "Kausetava\nMetals: {FFFF00}%i{ffffff} KG", FactoryInfo[1][mMineral]);
tPickup[19] = Create3DTextLabel(string,0xFFFFFFFF,-2146.3044,-261.8197,37.5156,50.0,0,0);
This is one of the few fuctions on my server that is using sql. Other values are being loaded from text files.
The problem is that the 3dTextLabel cant find FactoryInfo[1][mMineral] when the server starts and i must manually call it with a command.
Код:
	SetFactoryInt(1, "mineral", FactoryInfo[1][mMineral]);
	format(string, 50, "Kausetava\nMetals: {FFFF00}%i{ffffff} KG", FactoryInfo[1][mMineral]);
	Update3DTextLabelText(tPickup[19], 0xffffffff, string);
Heres SetFactoryInt:
Код:
stock SetFactoryInt(idx, stolb[], znach)
{
	new Query[128];
	format(Query, sizeof(Query), "UPDATE "TABLE_FACTORY" SET  %s = '%d' WHERE mmid = '%d' LIMIT 1", stolb, znach, idx);
    return mysql_query(Query);
}
Heres what i load when the server starts
Код:
stock LoadFactory()
{
    new query[2048];
    new time = GetTickCount();
    mysql_query("SELECT * FROM `"TABLE_FACTORY"`");
	mysql_store_result();
	if(mysql_num_rows() > 0)
	{
		for(new idx = 1; idx <= mysql_num_rows(); idx++)
		{
		   	mysql_fetch_row(query);
        	sscanf(query, "p<|>iiffffiiis[128]iiis[128]",
			FactoryInfo[idx][mMineral],
        }
		sscanf(FactoryInfo[1][mMetals], "p<,>iiiii", FactoryInfo[1], FactoryInfo[2], FactoryInfo[3], FactoryInfo[4], FactoryInfo[5]);
    }
    mysql_free_result();
    printf(" Tika ieladeta rupnica san fierro - %d pings %d (ms)", TOTALFACTORY,GetTickCount() - time);
}
There are other values loaded besides mMineral ofcourse.
:S
Reply
#4

I highily recommend you to switch to threaded queries since it is faster. I've used MySQL from R7 and earlier versions so I'm not aware of non-threaded queries.

Well, I can help you convert them if you want - a useful tutorial can be found here.
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
I highily recommend you to switch to threaded queries since it is faster. I've used MySQL from R7 and earlier versions so I'm not aware of non-threaded queries.

Well, I can help you convert them if you want - a useful tutorial can be found here.
Whats the difference from non-threaded queries and threaded queries? Arent they both providing information?
Reply
#6

Quote:
Originally Posted by Vince
Посмотреть сообщение
The idea with a threaded query is that while the query is busy the sa-mp server can continue on and execute other things (sync!). When the query is done, the MySQL servers calls the function you specify and you can go on loading your data.

With an unthreaded query, the sa-mp server has to wait for the response from the MySQL server before it can continue. This is especially troublesome if the query takes more than a few milliseconds to execute. During this "timeout" nothing happens. No syncing, nothing.
It pretty much explains everything.
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
It pretty much explains everything.
Alright... but lets get back on topic. Even if i convert them to threaded queries now, they wont read the data i need, when the server starts.
Reply
#8

That's why I told you to use threaded queries at the first place - it's faster and I know how to use it so I can help you to fix your problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)