SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 01/04/2009, 09:24 AM   #1
Coicatak
Huge Clucker
 
Join Date: Nov 2008
Posts: 318
Reputation: 0
Default Invalid func (SQL)

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 Code:
//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
Coicatak is offline  
Old 01/04/2009, 10:01 AM   #2
MenaceX^
High-roller
 
Join Date: Aug 2008
Posts: 3,262
Reputation: 13
Default Re: Invalid func (SQL)

Use samp_mysql_strtok.
MenaceX^ is offline  
Old 01/04/2009, 10:10 AM   #3
Coicatak
Huge Clucker
 
Join Date: Nov 2008
Posts: 318
Reputation: 0
Default Re: Invalid func (SQL)

Quote:
Originally Posted by MenaceX^
Use samp_mysql_strtok.
How does it work? I've never used it
Coicatak is offline  
Old 01/04/2009, 10:49 AM   #4
tom_jonez
Huge Clucker
 
Join Date: Dec 2007
Posts: 219
Reputation: 0
Default Re: Invalid func (SQL)

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.
tom_jonez is offline  
Old 01/04/2009, 01:59 PM   #5
Coicatak
Huge Clucker
 
Join Date: Nov 2008
Posts: 318
Reputation: 0
Default Re: Invalid func (SQL)

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

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [FS] AntiCheat & pr0tection 0.4 by And3rs !New FUNC! And3rs Filterscripts 15 30/09/2011 11:22 PM
[FUNC] ReadMyText Function Torran Help Archive 13 03/04/2010 05:13 PM
[FUNC] GetFreeVehicleSeats sean5874 Help Archive 5 01/04/2010 02:49 PM
[FUNC] Usefull Commands <- Fixed CJ101 Filterscripts 4 17/05/2009 12:52 AM


All times are GMT. The time now is 03:20 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.