SA-MP Forums Archive
Mysql Vehicle Load Issue/bug - 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 Vehicle Load Issue/bug (/showthread.php?tid=334345)



Mysql Vehicle Load Issue/bug - Abreezy - 14.04.2012

Well, I can't figure out this issue in this code, so hopefully someone on these forums could.

Here's the debug log, it shows that it's working:

pawn Код:
CMySQLHandler::FetchRow() - Return: 1|TWF-6561|560|103.146|1.17058|0.797754|0|1|1|State|42
Here's the loading:

pawn Код:
stock LoadCars()
{
    new Query[255];
    for(new id; id < MAX_CARS; id++)
    {
        format(Query, sizeof(Query), "SELECT * FROM Vehicles WHERE ID = %d", id);
        mysql_query(Query);
        mysql_store_result();
        if(mysql_num_rows())
        if(mysql_fetch_row_format(Query,"|"))
        {
            sscanf(Query, "p<|>e<iffff>", Vehicles[id]);
             printf("Model = %i",Vehicles[id][Model]);
            CreateVehicle(Vehicles[id][Model],Vehicles[id][Posx],Vehicles[id][Posy],Vehicles[id][Posz],Vehicles[id][Posa],1,1, 60*10000);
            printf("Model = %i",Vehicles[id][Model]);
           
        }
    }
}

On the printf it says:

pawn Код:
12:16:18] Model = 0
[12:16:18] Model = 0
[12:16:24] Server has been started.
[12:16:24] Number of vehicle models: 0
It shows no vehicles models, and the model comes out as 0 on there, which I can't understand.

Here's my enum:

pawn Код:
enum cars            
{
    Plate[12],
    Model,
    Float:Posx,
    Float:Posy,
    Float:Posz,
    Float:Posa,
    Color1,
    Color2,
    Owner[32],
    Fuel
};

Thanks in advance to anyone who posts.


Re: Mysql Vehicle Load Issue/bug - gabitzu4ever - 14.04.2012

id++;


Re: Mysql Vehicle Load Issue/bug - Abreezy - 14.04.2012

Quote:
Originally Posted by gabitzu4ever
Посмотреть сообщение
id++;
What?


Re: Mysql Vehicle Load Issue/bug - iggy1 - 14.04.2012

I think its because the sscanf specifiers don't match your enum. There is an array before the int and floats. I've never used sscanf with enums before so i'm not sure.


Re: Mysql Vehicle Load Issue/bug - fordawinzz - 14.04.2012

pawn Код:
sscanf(Query, "p<|>e<is[32]iffffiis[24]i>", Vehicles[id]);

enum cars            
{
    cID,
    Plate[32],
    Model,
    Float:Posx,
    Float:Posy,
    Float:Posz,
    Float:Posa,
    Color1,
    Color2,
    Owner[MAX_PLAYER_NAME],
    Fuel
};
I'm not 100% sure this will work because I don't know what do you have in your table.


Re: Mysql Vehicle Load Issue/bug - iggy1 - 14.04.2012

Quote:
Originally Posted by fordawinzz
Посмотреть сообщение
pawn Код:
sscanf(Query, "p<|>e<is[32]iffffiis[24]i>", Vehicles[id]);

enum cars            
{
    cID,
    Plate[32],
    Model,
    Float:Posx,
    Float:Posy,
    Float:Posz,
    Float:Posa,
    Color1,
    Color2,
    Owner[MAX_PLAYER_NAME],
    Fuel
};
Thats how it should be but your query doesn't return data in that order

EDIT: oops it does if you use that^^ enum.


Re: Mysql Vehicle Load Issue/bug - fordawinzz - 14.04.2012

Yeah, it will do because he uses the 'ID' row in his table but it is not in his enum, that's why his system won't work

EDIT: Try using my code, it should work.


Re: Mysql Vehicle Load Issue/bug - Abreezy - 14.04.2012

pawn Код:
ID
Plate  
Model
Posx
Posy
Posz
Posa   
Color1
Color2
Owner
Fuel
That's my table on PHP


Re: Mysql Vehicle Load Issue/bug - iggy1 - 14.04.2012

Yeah i edited my post 3 secs after posting it . Use fordawinzz enum and sscanf line, should work.


Re: Mysql Vehicle Load Issue/bug - Abreezy - 14.04.2012

Thanks guys, It worked this time =]