MySQL Loading HELP AGAIN!!! -
Kraeror - 06.01.2018
Hello guys, I'm using the latest MySQL version, but when I load it, it works only for the callback, that I'm loading in it! Is it possible somethink like when I load at the start script it will be loaded for all commands, callbacks?
It is loading, I'm using it in the same callback, where it is loaded, but when I'm using it in command it is always "0".
The code (OnGameModeInit callback):
PHP код:
for(new h = 1; h < cache_num_rows(); h++)
{
mysql_format(zMySQL, query, sizeof(query), "SELECT * FROM `houses` WHERE `ID` = %d", h);
mysql_tquery(zMySQL, query, "LoadHouses", "i", h);
}
And there is my loading callback:
PHP код:
forward LoadHouses(houseid);
public LoadHouses(houseid)
{
new NumRows;
cache_get_row_count(NumRows);
if(numRows != 0)
{
for(new i = 0; i < NumRows; i++)
{
cache_get_value_name(i, "Position:X", HouseInfo[i][hX]);
printf("%f", HouseInfo[i][hX]);
}
}
return 1;
}
This result is printed
CORRECT, but when I'm using this variable or another callback in command it
prints "0"!
Re: MySQL Loading -
Kane - 06.01.2018
Where is
cache_num_rows coming from in OnGameModeInit()?
An example of a proper loading:
PHP код:
public OnGameModeInit(){
mysql_tquery(DB, "SELECT * FROM `houses` ORDER BY `dbid` ASC", "Thread_LoadHouses");
return 1;
}
Thread_LoadHouses(); public Thread_LoadHouses()
{
if (!cache_num_rows()) {
return 1;
}
for (new i = 1, j = 0; j < cache_num_rows(); i++, j++) {
cache_get_value_float(j, "HousePosX", Houses[i][HousePos][0]);
cache_get_value_float(j, "HousePosY", Houses[i][HousePos][1]);
cache_get_value_float(j, "HousePosZ", Houses[i][HousePos][2]);
}
return 1;
}
Re: MySQL Loading -
Kraeror - 06.01.2018
What means `dbid` and ASC ?
Can you describe it for me please
?
Re: MySQL Loading -
Kraeror - 06.01.2018
EDITED: FIXED!!!!!!!! dbid was `ID` in my database, THANK YOU VERY MUCH! +1 REEEEPPPPP
Re: MySQL Loading -
Kane - 06.01.2018
ASC is ascending.
Re: MySQL Loading -
Kraeror - 06.01.2018
Thank you for the information!! THANK YOU FOR ALL!!!!!!!!!!!!!!!!!!!!!!
Re: MySQL Loading -
Kraeror - 07.01.2018
I have one more problem! I can't find the number of rows, because I want to create one more row (a house)! Firstly when I start the server I can create one house and it is saving perfect, but when I try to create one more I have to restart the server again, because when I'm trying to create second house, it is not saving! The problem is because the rows are counted only one time (but in the script I'm counting them always when I want to create the ouse)
Here is my creating house command: (I'm testing the number, when I have created one house it works correct, but when I'm trying to create another one it doesn't counts) Please help me guys!)
PHP код:
mysql_tquery(zMySQL, "SELECT * FROM `houses` ORDER BY `ID` ASC");
new h = cache_num_rows()+1;
printf("%d", h);
Re: MySQL Loading -
Kraeror - 07.01.2018
Anybody help
?