SA-MP Forums Archive
mysql - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: mysql (/showthread.php?tid=225394)



mysql - iJumbo - 13.02.2011

why this dont load any car?

pawn Код:
stock L()
{
    new
        Query[512],
        vModel2,
        vC[2],
        vID,
        Float:Pos[4];

    mysql_query("SELECT * FROM `veh`");
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row(Query))
        {
            sscanf(Query, "p<|>iiiffff",vModel2, vC[0], vC[1], Pos[0], Pos[1], Pos[2], Pos[3]);
            CreateVehicle(vModel2, Pos[0], Pos[1], Pos[2], Pos[3], vC[0], vC[1], 500000);
        }
    }
    mysql_free_result();
    return 1;
}



Re: mysql - wups - 13.02.2011

Are your tables okay?
Try mysql_debug.


- iJumbo - 13.02.2011

pawn Код:
stock L()
{
    new Str[67], dModel, Float:VX, Float:VY, Float:VZ, Float:VA, vTotal;
    mysql_query("SELECT * FROM `vehicles`");
    mysql_store_result();
    vTotal = mysql_num_rows();
    if(vTotal > 0)
    {
        while(mysql_fetch_row(Str))
        {
            sscanf(Str, "p<|>iffff", dModel, VX, VY, VZ, VA);
            new VID = CreateVehicle(dModel, VX, VY, VZ, VA, -1, -1, (30 * 60));
            SetVehicleNumberPlate(VID,"ISS");
        }
    }
    mysql_free_result();
    printf("%i vehicle loaded", vTotal);
    return 1;
}
i change the code to this ...

but WHY i dont see any car!!!!

server log

17 vehicle loaded
Number of vehicle models: 1 <<<<< whyyy no spawn a car!!!


Re: mysql - JaTochNietDan - 13.02.2011

Do some debugging to make sure that the information coming out is accurate, for example:

pawn Код:
stock L()
{
    new Str[67], dModel, Float:VX, Float:VY, Float:VZ, Float:VA, vTotal;
    mysql_query("SELECT * FROM `vehicles`");
    mysql_store_result();
    vTotal = mysql_num_rows();
    if(vTotal > 0)
    {
        while(mysql_fetch_row(Str))
        {
            printf("Row: %s",str);
            sscanf(Str, "p<|>iffff", dModel, VX, VY, VZ, VA);
            new VID = CreateVehicle(dModel, VX, VY, VZ, VA, -1, -1, (30 * 60));
            SetVehicleNumberPlate(VID,"ISS");
        }
    }
    mysql_free_result();
    printf("%i vehicle loaded", vTotal);
    return 1;
}



Re: mysql - iJumbo - 13.02.2011

pawn Код:
[21:22:54] Row: 506|-265.242|1542.86|75.0637|314.037|1
[21:22:54] Row: 506|-267.705|1545.26|75.0637|315.489|2
[21:22:54] Row: 506|-270.114|1547.74|75.0639|313.933|3
[21:22:54] Row: 506|-272.664|1550.23|75.0639|314.754|4
[21:22:54] Row: 506|-275.001|1552.9|75.0638|314.718|5
[21:22:54] Row: 562|-277.523|1555.18|75.019|314.058|6
[21:22:54] Row: 562|-280.35|1557.41|75.0183|313.936|7
[21:22:54] Row: 562|-282.518|1560.02|75.0185|314.514|8
[21:22:54] Row: 562|-285.198|1562.39|75.0175|314.769|9
[21:22:54] Row: 562|-321.063|1515.29|75.0163|180|10
[21:22:54] Row: 562|-324.022|1515.56|75.0187|179.948|11
[21:22:54] Row: 562|-327.258|1515.53|75.0184|179.944|12
[21:22:54] Row: 562|-330.37|1515.39|75.0189|179.054|13
[21:22:54] Row: 562|-333.467|1515.4|75.0174|179.423|14
[21:22:54] Row: 560|-339.862|1514.99|75.0644|180.449|15
[21:22:54] Row: 560|-342.933|1515.51|75.0641|180.34|16
[21:22:54] Row: 560|-345.782|1515.66|75.064|180.2|17
[21:22:54] 17 vehicle loaded
i get all right cords ... its all ok but no vehicle spawn


Re: mysql - JaTochNietDan - 13.02.2011

Okay, tell me what this prints:

pawn Код:
stock L()
{
    new Str[67], dModel, Float:VX, Float:VY, Float:VZ, Float:VA, vTotal;
    mysql_query("SELECT * FROM `vehicles`");
    mysql_store_result();
    vTotal = mysql_num_rows();
    if(vTotal > 0)
    {
        while(mysql_fetch_row(Str))
        {
            printf("Row: %s",str);
            sscanf(Str, "p<|>iffff", dModel, VX, VY, VZ, VA);
            printf("Model: %d | VX: %f | VY: %f | VZ: %f | VA: %f",dModel,VX,VY,VZ,VA);
            new VID = CreateVehicle(dModel, VX, VY, VZ, VA, -1, -1, (30 * 60));
            SetVehicleNumberPlate(VID,"ISS");
        }
    }
    mysql_free_result();
    printf("%i vehicle loaded", vTotal);
    return 1;
}
Additionally what version of sscanf are you using? The plugin version or the old include version?


Re: mysql - iJumbo - 13.02.2011

AHahhhhhhhh we got the problem! i get all sscanf result to 0 and 0.000000 umm i use old include


Re: mysql - JaTochNietDan - 13.02.2011

Okay the problem is in your sscanf syntax, the old include version doesn't support the delimiter being in brackets, you need to just put it there on its own next to p. I recommend using the latest plugin version of sscanf of course, however if you wish to stick with the old version, here is the fixed syntax for that version:

pawn Код:
sscanf(Str, "p|iffff", dModel, VX, VY, VZ, VA);



Re: mysql - iJumbo - 13.02.2011

thx very much for your help !