PDA

View Full Version : Simple question - can dini be mixed with sql?


Unri
27/09/2013, 02:12 PM
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.

Konstantinos
27/09/2013, 02:15 PM
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?

Unri
27/09/2013, 02:23 PM
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

Konstantinos
27/09/2013, 02:29 PM
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 (http://forum.sa-mp.com/showthread.php?t=337810).

Unri
27/09/2013, 02:30 PM
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 (http://forum.sa-mp.com/showthread.php?t=337810).

Whats the difference from non-threaded queries and threaded queries? Arent they both providing information?

Konstantinos
27/09/2013, 02:33 PM
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.

Unri
27/09/2013, 02:37 PM
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.

Konstantinos
27/09/2013, 02:46 PM
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.