23.03.2013, 11:18
I'm rather new to the mysql things.. I've been trying to convert my gate system to mysql, and it has gone very well. Everything works (creating, deleting & saving) except for loading the coordinates, model, speed, password and so on.
When I use any of the information I've fetched using mysql_fetch_field row, it outputs zero. Like in the format & print I did to 'debug'. Everything comes out zero (except for the 988 ofcourse.)
pawn Код:
LoadGates(playerid)
{
for(new i = 0; i != MAX_GATES; i++)
{
if(GateInfo[i][gCreated] == 0)
{
new query[300];
new string[64];
new savingstring[20];
format(query, sizeof(query), "SELECT model, x, y, z, xm, ym, zm, rx, ry, rz, speed, password WHERE id = '%d'", i);
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query, "|"))
{
mysql_fetch_field_row(savingstring, "model"); GateInfo[i][gModel] = strval(savingstring);
mysql_fetch_field_row(savingstring, "x"); GateInfo[i][gPosX] = strval(savingstring);
mysql_fetch_field_row(savingstring, "y"); GateInfo[i][gPosY] = strval(savingstring);
mysql_fetch_field_row(savingstring, "z"); GateInfo[i][gPosZ] = strval(savingstring);
mysql_fetch_field_row(savingstring, "xm"); GateInfo[i][gPosXM] = strval(savingstring);
mysql_fetch_field_row(savingstring, "ym"); GateInfo[i][gPosYM] = strval(savingstring);
mysql_fetch_field_row(savingstring, "zm"); GateInfo[i][gPosZM] = strval(savingstring);
mysql_fetch_field_row(savingstring, "rx"); GateInfo[i][gRX] = strval(savingstring);
mysql_fetch_field_row(savingstring, "ry"); GateInfo[i][gRY] = strval(savingstring);
mysql_fetch_field_row(savingstring, "rz"); GateInfo[i][gRZ] = strval(savingstring);
mysql_fetch_field_row(savingstring, "speed"); GateInfo[i][gSpeed] = strval(savingstring);
mysql_fetch_field_row(savingstring, "status"); GateInfo[i][gStatus] = strval(savingstring);
mysql_fetch_field_row(savingstring, "password"); GateInfo[i][gPassword] = strval(savingstring);
}
GateInfo[i][gObject] = CreateObject(988, GateInfo[i][gPosX], GateInfo[i][gPosY], GateInfo[i][gPosZ], 0, 0, 0);
//GateInfo[i][gObject] = CreateObject(GateInfo[i][gModel], GateInfo[i][gPosX], GateInfo[i][gPosY], GateInfo[i][gPosZ], GateInfo[i][gRX], GateInfo[i][gRY], GateInfo[i][gRZ]);
GateInfo[i][gNear] = IsPlayerInRangeOfPoint(playerid, 15.0, GateInfo[i][gPosX], GateInfo[i][gPosY], GateInfo[i][gPosZ]);
format(string, sizeof(string), "988, %f, %f, %f, 0, 0, 0", GateInfo[i][gPosX], GateInfo[i][gPosY], GateInfo[i][gPosZ]);
print(string);
}
}
}