Load Mysql cars
#5

thanks for the tutorial link @Vince:

my source right now
Код:
stock LoadPlayerCars()
{

    mysql_query_callback(1, "SELECT * FROM cars",  "OnPlayerCarsLoaded"); // we won't pass any other variables to the callback
}
forward OnPlayerCarsLoaded();
public OnPlayerCarsLoaded()
{
    new
        idx,
        result[256],
        query[128];
	new downer,dplate,Float:sx,Float:sy,Float:sz,model,colo1,colo2,dprice,dcar,iD,Float:sr;
    format(result, 128, "SELECT * FROM `cars` WHERE `ID` = '%d'", id);
	mysql_query(query);
    mysql_store_result();

    // Here we start the while loop to fetch the rows
    while(mysql_fetch_row_format(result, "|"))
    {
        sscanf(result, "e<p<|>{i}is[16]s[24]ffffiiii>",iD,downer,dplate,sx,sy,sz,sr,model,colo1,colo2,dprice);
		Playercar[idx][owner] = downer;
		Playercar[idx][plate] = dplate;
		Playercar[idx][spawnx] = sx;
		Playercar[idx][spawny] = sy;
		Playercar[idx][spawnz] = sz;
		Playercar[idx][spawnr] = sr;
		Playercar[idx][modelid] = model;
		Playercar[idx][c1] = colo1;
		Playercar[idx][c2] = colo2;
		Playercar[idx][price] = dprice;
        Playercar[idx][car] = AddStaticVehicleEx(Playercar[idx][modelid],Playercar[idx][spawnx],Playercar[idx][spawny],Playercar[idx][spawnz],Playercar[idx][spawnr],Playercar[idx][c1],Playercar[idx][c2],60);
        idx++; // Now increment our index!
    }

    mysql_free_result();
    printf("[mysql] Succesful. Fetched %i rows from the database.", idx); //
    return 1;
}
It fetched 3 rows, thats okay cause i 've got 3 in my DB.
But my car doesnt appear. Did i do it correctly? Or is sth wrong?

#edit
i printed it.
printf(" ||CAR: %s %i %f %f %f %f %i %i %i", downer,modelid,sx,sy,sz,sr,colo1,colo2,price);
the output is
Код:
||CAR:  49 0.000000 0.000000 0.000000 0.000000 0 0 52
Wheres the mistake?
Reply


Messages In This Thread
Load Mysql cars - by yellow - 02.02.2014, 14:05
AW: Load Mysql cars - by yellow - 02.02.2014, 16:45
Re: Load Mysql cars - by Vince - 02.02.2014, 17:17
Re: Load Mysql cars - by PowerPC603 - 02.02.2014, 18:05
AW: Load Mysql cars - by yellow - 02.02.2014, 18:14
Re: Load Mysql cars - by PowerPC603 - 02.02.2014, 18:51
AW: Load Mysql cars - by yellow - 02.02.2014, 18:58
Re: Load Mysql cars - by PowerPC603 - 02.02.2014, 19:00
AW: Load Mysql cars - by yellow - 02.02.2014, 19:02
Re: Load Mysql cars - by PowerPC603 - 02.02.2014, 19:04

Forum Jump:


Users browsing this thread: 1 Guest(s)