SA-MP Forums Archive
MySQL problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL problem (/showthread.php?tid=345760)



MySQL problem - N0FeaR - 26.05.2012

Hello, i have like 60 cars in my MySQL when i try add more they wont load it

here is the load code

pawn Код:
forward LoadCityCars();
public LoadCityCars()
{
    mysql_query("SELECT * FROM Vehicles ORDER BY carid");
    mysql_store_result();
    new data[11][512];
    new string[1024];
    while(mysql_fetch_row(string,"|"))
    {
        //if(mysql_num_rows() == 0) continue;
        split(string, data, '|');
        //printf(string);
        new Carid = CreateVehicle(strval(data[1]), floatstr(data[2]), floatstr(data[3]), floatstr(data[4]), floatstr(data[5]), strval(data[6]), strval(data[7]), 60000);
        DynamicCars[Carid][FactionCar] = strval(data[8]);
        DynamicCars[Carid][CarType] = strval(data[9]);
        strmid(DynamicCars[Carid][cDescription], data[10], 0, strlen(data[10]), 255);
        SetVehicleNumberPlate(Carid, "XMT 3432");
        SetVehicleToRespawn(Carid);
        if(Carid == IBPCARS)
        {
            mysql_free_result();
            return 0;
        }
    }
    return 1;
}



Re: MySQL problem - JaTochNietDan - 26.05.2012

Well this statement here:

pawn Код:
if(Carid == IBPCARS)
{
    mysql_free_result();
    return 0;
}
Will cause the loop to end prematurely if the condition is met, so what is the value of IBPCARS and do you think that this statement can be true before the end of the loop?

In fact, why do you have it in the first place?


Re: MySQL problem - N0FeaR - 26.05.2012

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Well this statement here:

pawn Код:
if(Carid == IBPCARS)
{
    mysql_free_result();
    return 0;
}
Will cause the loop to end prematurely if the condition is met, so what is the value of IBPCARS and do you think that this statement can be true before the end of the loop?

In fact, why do you have it in the first place?
My friend helped me with script the loadcar in my MySQL.


Re: MySQL problem - JaTochNietDan - 26.05.2012

Okay, but that doesn't answer my question.

Is there a reason it's there? It's possibly (and probably) what's causing the interference, so if there is no reason that it's there, simply remove it!


- N0FeaR - 26.05.2012

No, there is no reason why it's there, i will try.

Yes, have i reason cus when i remove it, then the script goes crazy.


Re: MySQL problem - JaTochNietDan - 26.05.2012

Quote:
Originally Posted by N0FeaR
Посмотреть сообщение
No, there is no reason why it's there, i will try.

Yes, have i reason cus when i remove it, then the script goes crazy.
What do you mean it goes crazy? That doesn't help anyone solve anything.


Re: MySQL problem - N0FeaR - 26.05.2012

I can complie without erros but all objects in game just disappear

when i add this again the objects come back

pawn Код:
if(Carid == IBPCARS)
{
    mysql_free_result();
    return 0;
}



Re: MySQL problem - JaTochNietDan - 26.05.2012

Quote:
Originally Posted by N0FeaR
Посмотреть сообщение
I can complie without erros but all objects in game just disappear

when i add this again the objects come back

pawn Код:
if(Carid == IBPCARS)
{
    mysql_free_result();
    return 0;
}
Well what is IBPCARS? What value does it hold?


Re: MySQL problem - N0FeaR - 26.05.2012

Nvm is fixed now, thank you.