SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 21/04/2011, 07:43 PM   #1
Hornet600
Big Clucker
 
Join Date: Oct 2010
Posts: 124
Reputation: 0
Default [Help] Function load failing

I write this code and it was working very well but i depared with something was lefting so i added it but this is making the load thing stop and not loading at all... I added the vid and made it loop trought all cars and it is stoping the load thing i dont know why if I remove the vid thing it will load. Any help? I know is a lot of code but is clean and easy to understand.Thank you!

pawn Code:
stock LoadGlobalVehicles()
{
    new query[1021];
    new count = 0;
    for(new i; i < MAX_VEHICLES; i++)
    {
        format(query, sizeof(query),"SELECT * FROM vehicles WHERE carid= %d && Type != 1",i);
        mysql_query(query);
        mysql_store_result();
        if(mysql_num_rows())
        {
       
        }
        else
        { printf("fail"); return 1;}
        if(mysql_fetch_row(query, "|"))
        {
                        new field[17][64];
                        explode(query, field, "|");
                        mysql_free_result();
                        count++;
                        vehicleinfo[i][id] = strval(field[0]);
                        vehicleinfo[i][Model] = strval(field[1]);
                        vehicleinfo[i][Color1] = strval(field[2]);
                        vehicleinfo[i][Color2] = strval(field[3]);
                        vehicleinfo[i][x] = strval(field[4]);
                        vehicleinfo[i][y] = strval(field[5]);
                        vehicleinfo[i][z] = strval(field[6]);
                        vehicleinfo[i][a] = strval(field[7]);
                        strcpy(vehicleinfo[i][Owner], field[8], 24);
                        strcpy(vehicleinfo[i][Name], field[9], 24);
                        vehicleinfo[i][Lock] = strval(field[10]);
                        vehicleinfo[i][Insurances] = strval(field[11]);
                        vehicleinfo[i][Destroyed] = strval(field[12]);
                        vehicleinfo[i][IPrice] = strval(field[13]);
                        vehicleinfo[i][Radio] = strval(field[14]);
                        vehicleinfo[i][Type] = strval(field[15]);
                        vehicleinfo[i][Engine] = strval(field[16]);
                        new vid[MAX_VEHICLES];
                        vid[i] = CreateVehicle(vehicleinfo[i][Model],vehicleinfo[i][x],vehicleinfo[i][y],vehicleinfo[i][z],
                        vehicleinfo[i][a],vehicleinfo[i][Color1],vehicleinfo[i][Color2],100*1500);
                        vehiclekey[vid[i]] = i;

        }
       

    }
    printf("Loaded %d vehicles.",count);
    return 1;
}
Hornet600 is offline  
Old 21/04/2011, 08:18 PM   #2
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,068
Reputation: 2658
Default Re: [Help] Function load failing

Try it like:

pawn Code:
new i = 0;

mysql_query("SELECT * FROM vehicles WHERE Type != 1");
mysql_store_result():

while(mysql_fetch_row_format(query, "|"))
{
    // Extract stuff from the current line here
    // use the i variable as index for your vehicleinfo
    i++;
}

mysql_free_result();
__________________
Vince is offline  
Old 21/04/2011, 08:38 PM   #3
Hornet600
Big Clucker
 
Join Date: Oct 2010
Posts: 124
Reputation: 0
Default Re: [Help] Function load failing

Thanks should i make loop throght max vehicles?
Hornet600 is offline  
Old 21/04/2011, 08:43 PM   #4
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,068
Reputation: 2658
Default Re: [Help] Function load failing

No..
__________________
Vince 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
Failing with basics willsuckformoney Help Archive 2 06/08/2010 03:59 PM
SA:MP failing to connect MikeW121 Client Support 3 05/06/2010 04:23 PM
MySQL error - when load the function mysql_fetch_row Mandrakke Help Archive 0 11/04/2010 02:52 AM
Wtf is going on here. the save fuctions or the load function? addysnow1 Help Archive 0 24/01/2010 05:09 PM
Failing to load plugins & 'Runtime Error 19' ledzep Server Support 6 24/01/2009 12:14 AM


All times are GMT. The time now is 03:50 PM.


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