Mysql loading tables - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Mysql loading tables (
/showthread.php?tid=526521)
Mysql loading tables -
TakeiT - 17.07.2014
This ties in with the last thread I made (
https://sampforum.blast.hk/showthread.php?tid=526506)
I can't seem to figure this out, though i'm sure it's simple..
The objects are only loading into the server from the last project created. (the highest id) I'm assuming it has something to do with my use of a loop inside of a loop, but I don't really know another way to do this, i've never attempted anything of this sort before. Anyhow, this is my loading function.
pawn Код:
stock LoadObjects()
{
for(new project; project<GetCreatedProjects()+1; project++)
{
for(new i; i<GetCreatedObjects(project)+1; i++)
{
LoadObject(project, i);
}
}
}
stock LoadObject(project, id)
{
new Query[800], string[50];
format(Query, sizeof(Query), "SELECT * FROM `Project_%d` WHERE `ID` = %d", project, id);
mysql_query(Query);
mysql_store_result();
while(mysql_fetch_row_format(Query,"|"))
{
mysql_fetch_field_row(string, "ID");
ObjectInfo[id][oID] = strval(string);
mysql_fetch_field_row(string, "MODEL");
ObjectInfo[id][oModel] = strval(string);
mysql_fetch_field_row(string, "X");
ObjectInfo[id][oX] = floatstr(string);
mysql_fetch_field_row(string, "Y");
ObjectInfo[id][oY] = floatstr(string);
mysql_fetch_field_row(string, "Z");
ObjectInfo[id][oZ] = floatstr(string);
mysql_fetch_field_row(string, "RX");
ObjectInfo[id][orX] = floatstr(string);
mysql_fetch_field_row(string, "RY");
ObjectInfo[id][orY] = floatstr(string);
mysql_fetch_field_row(string, "RZ");
ObjectInfo[id][orZ] = floatstr(string);
}
mysql_free_result();
ObjectInfo[id][oProject] = project;
return 1;
}
Re: Mysql loading tables -
TakeiT - 17.07.2014
Okay, I just realized the issue, i'm not 100% sure how to fix it, but what's happening is everytime it loads a project, it's writing it to a new 'id' in ObjectInfo
EDIT: I have no clue how to fix this without eliminating the array alltogether and directly pull all the info from the database directly.
Re: Mysql loading tables -
Hanger - 18.07.2014
try to start it out from 0, just to be sure.
Код:
for(new project=0; project<GetCreatedProjects()+1; project++)
{
for(new i=0; i<GetCreatedObjects(project)+1; i++)
{
edit:
your problem also might be the unique and auto-increment inside the mysql itself.
Re: Mysql loading tables -
TakeiT - 18.07.2014
Quote:
Originally Posted by Hanger
try to start it out from 0, just to be sure.
Код:
for(new project=0; project<GetCreatedProjects()+1; project++)
{
for(new i=0; i<GetCreatedObjects(project)+1; i++)
{
edit:
your problem also might be the unique and auto-increment inside the mysql itself.
|
I've sorted through all of that, I know for sure that in the array
ObjectInfo[ID][oInfo]; the ID is being written over.
Re: Mysql loading tables -
TakeiT - 18.07.2014
Used a 3D variable for the enum on the objects, works now.