Invalid func (SQL)
#1

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?

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, &#39;|'); // 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);
}
And my DB:


I have only one line at the moment
Reply
#2

Use samp_mysql_strtok.
Reply
#3

Quote:
Originally Posted by MenaceX^
Use samp_mysql_strtok.
How does it work? I've never used it
Reply
#4

Yeah, here u go: http://lostgangwarz.free.fr/samp_mys...p_mysql_strtok
Its stupid that u need to do this, someone needs to get the mysql_fetch_array working. =/ It sucks using it this way.
Reply
#5

I don't manage to make it work, can someone show me how the func should be please?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)