21.08.2011, 19:58
Hi, today I made a simple mysql property system, the problem is these properties won't load.
My code is:
Mysql log reported everything correctly..
I am afraid the problem is in mysql_num_rows() or sscanf, can someone help?
My code is:
Code:
public LoadProperties()
{
new query[300];
format(query,sizeof(query),"SELECT * FROM properties");
mysql_query(query);
mysql_store_result();
new rows = mysql_num_rows();
for(new i; i < MAX_BIZZ; i++)
{
if(rows)
{
sscanf(query,"ds[50]s[24]ddddffffff",
Bizz[i][id],
Bizz[i][name],
Bizz[i][owner],
Bizz[i][status],
Bizz[i][type],
Bizz[i][vault],
Bizz[i][interior],
Bizz[i][intx],
Bizz[i][inty],
Bizz[i][intz],
Bizz[i][outx],
Bizz[i][outy],
Bizz[i][outz]);
new
x,
y,
z,
label[150],
btype[24];
Bizz[i][outx] = x;
Bizz[i][outy] = y;
Bizz[i][outz] = z;
if(Bizz[i][type] == 0) { btype = "n/a"; }
else if(Bizz[i][type] == 1) { btype = "Shop";}
if(Bizz[id][status] == 1)
{
format(label,sizeof(label),"%s\nOwner: %s | Type: %s\nStatus: Open | ID: %d",Bizz[i][name],Bizz[i][owner],i);
Create3DTextLabel(label,0x008080FF,x,y,z,40.0,0);
}
else
{
if(strval(Bizz[id][owner]))
{
format(label,sizeof(label),"%s\nOwner: %s | Type: %s\nStatus: Closed | ID: %d",Bizz[i][name],Bizz[i][owner],i);
Create3DTextLabel(label,0x008080FF,x,y,z,40.0,0);
}
else
{
format(label,sizeof(label),"%s\nOwner: %s | Type: %s\nStatus: Closed | ID: %d",Bizz[i][name],Bizz[i][owner],i);
Create3DTextLabel(label,0x008080FF,x,y,z,40.0,0);
}
}
printf("bizz %d loaded!",i);
PrintPropertyStats(i);
}
else print("no rows");
}
mysql_free_result();
return 1;
}
I am afraid the problem is in mysql_num_rows() or sscanf, can someone help?

