Help with mysql load pickups -
lutherfchen - 31.01.2016
LoadDynamics()
{
new query[128];
for(new i = 0; i < MAX_DYNAMICS; i++)
{
format(query, sizeof(query), "SELECT * FROM `dynamics` WHERE `ID` = '%d'", i);
mysql_query(mysql, query);
dInfo[i][ID] = i;
dInfo[i][pModel] = cache_get_field_content_int(0, "pModel");
}
return 1;
}
Why it wont work? I have tried many times but didnt found any solution.
Re: Help with mysql load pickups -
Mencent - 31.01.2016
Do it like this:
PHP код:
LoadDynamics()
{
new query[128];
for(new i;i<MAX_DYNAMICS;i++)
{
format(query,sizeof query,"SELECT * FROM `dynamics` WHERE `ID`='%d'",i);
mysql_tquery(dbhandle,query,"OnLoadDynamics","i",i);
}
return 1;
}
forward OnLoadDynamics(i);
public OnLoadDynamics(i)
{
if(cache_num_rows() == 0)return 1;
dInfo[i][pModel] = cache_get_field_content_int(0,"pModel");
return 1;
}
Re: Help with mysql load pickups -
lutherfchen - 31.01.2016
Quote:
Originally Posted by Mencent
Do it like this:
PHP код:
LoadDynamics()
{
new query[128];
for(new i;i<MAX_DYNAMICS;i++)
{
format(query,sizeof query,"SELECT * FROM `dynamics` WHERE `ID`='%d'",i);
mysql_tquery(dbhandle,query,"OnLoadDynamics","i",i);
}
return 1;
}
forward OnLoadDynamics(i);
public OnLoadDynamics(i)
{
if(cache_num_rows() == 0)return 1;
dInfo[i][pModel] = cache_get_field_content_int(0,"pModel");
return 1;
}
|
thanks, but can you also look at this?
forward OnDynamicsLoad(i);
public OnDynamicsLoad(i)
{
if(cache_num_rows() == 0) return 1;
dInfo[i][ID] = i;
dInfo[i][pModel] = cache_get_field_content_int(0,"pModel");
printf("%d", dInfo[i][pModel]);//for debugging
return 1;
}
Why the printf doesnt work?
Re: Help with mysql load pickups -
Mencent - 31.01.2016
Hm, does it work if you do it like this?
PHP код:
forward OnDynamicsLoad(i);
public OnDynamicsLoad(i)
{
if(cache_num_rows() == 0) return 1;
dInfo[i][ID] = i;
dInfo[i][pModel] = cache_get_field_content_int(i,"pModel");
printf("%d", dInfo[i][pModel]);//for debugging
return 1;
}
Re: Help with mysql load pickups -
Vince - 31.01.2016
This is a horrible way to load multiple rows. Remember that you are not working with files. Instead of sending
n amount of requests and fetching one result at a time, you should send
one request and fetch
all results simultaneously.
pawn Код:
LoadDynamics()
{
mysql_tquery(dbhandle,"SELECT * FROM `Dynamics`, "OnLoadDynamics");
return 1;
}
forward OnLoadDynamics();
public OnLoadDynamics()
{
for(new i, rows = cache_num_rows(); i < rows; i++)
{
dInfo[i][pModel] = cache_get_field_content_int(i, "pModel");
}
return 1;
}
Re: Help with mysql load pickups -
lutherfchen - 31.01.2016
Thank you both, I just got it work
But I'm having another problem,
I use CreateDynamic3DText(dInfo[i][Text].......);
but when I enter the game it shows like [Police Department\nUse /enter]
the \n that I save in the mysql database doesnt work.. any idea? Thanks
Re: Help with mysql load pickups -
Vince - 31.01.2016
"\n" isn't the same as '\n'. Note the difference in quotes. The first is a
string and a combination of the literal characters \ and n whereas the latter one is the escape sequence for the non-printable newline
character. It is essentially the character that is generated when the return key is pressed. If the player types \ and n into a dialog then that is not the same as pressing the return key. Such sequences must be manually replaced by the script before storing them in the database.