01.04.2009, 09:24
Well, I've a problem with a func placed in OnGameModeInit, the split doesn't work and then all that is under the line "LoadSQLJobs();" in OnGameModeInit won't load. What's wrong?
And my DB:
I have only one line at the moment
pawn Код:
//At the top
enum jInfo
{
Float:jX,
Float:jY,
Float:jZ,
jMessage[80],
Float:jCheckX[20],
Float:jCheckY[20],
Float:jCheckZ[20]
}
new JobInfo[MAX_JOBS][jInfo];
//The function (forwarded)
public LoadSQLJobs()
{
new sql[64], f[75][64], row[256];
format(sql, sizeof(sql), "SELECT COUNT(*) FROM jobs");
samp_mysql_query(sql);
samp_mysql_store_result();
samp_mysql_fetch_row(row);
totaljobs = strval(row);
samp_mysql_free_result();
for (new i=1; i<=totaljobs; i++)
{
format(sql, sizeof(sql), "SELECT * FROM jobs WHERE id=%d", i);
samp_mysql_query(sql);
samp_mysql_store_result();
samp_mysql_fetch_row(row);
split(row, f, '|'); // This does not work
samp_mysql_free_result();
memcpy(JobInfo[i][jMessage], f[4], 0, 80*4, 80*4);
JobInfo[i][jX] = floatstr(f[1]);
JobInfo[i][jY] = floatstr(f[2]);
JobInfo[i][jZ] = floatstr(f[3]);
new x=5, y=6, z=7;
printf("[%d] X: %f Y: %f Z: %f", i, JobInfo[i][jX], JobInfo[i][jY], JobInfo[i][jZ]);
for(new c=0; c<20; c++)
{
JobInfo[i][jCheckX][c] = floatstr(f[x]);
JobInfo[i][jCheckY][c] = floatstr(f[y]);
JobInfo[i][jCheckZ][c] = floatstr(f[z]);
x += 3; y += 3; z+= 3;
printf("i=%d c=%d x=%d y=%d z=%d ", i, c, x, y, z);
printf("JobInfo[i][jCheckX][c] = %f && JobInfo[i][jCheckY][c] = %f", JobInfo[i][jCheckX][c], JobInfo[i][jCheckY][c]);
}
}
format(row, sizeof(row), "%d jobs loaded from the DB",totaljobs);
printf("%s", row);
}
I have only one line at the moment