Vehicle
#1

Hi all and thanks for have read this.
Where is the problem?

Код:
public LoadPlayerVehicles(playerid)
{
	new data[1024],loaded,row;
	new c,a,dbid,model,vowner,Float:posx,Float:posy,Float:posz,Float:posa,vcolor1,vcolor2,vpaintjob,vmod[128],vplate[20],vlock,vgas,vgps,vassi;
	format(Query,sizeof(Query),"SELECT * FROM `uvehicles` WHERE `owner` = %d",PlayerInfo[playerid][pDatabaseID]);
	mysql_query(Query);
	mysql_store_result();
	row = mysql_num_rows();
	for(new i = 0; i < row; i++)
	{
	    mysql_fetch_row(data,"|"); // Creo stringa dati
	    printf("%s",data);
        sscanf(data, "p<|>dddfffddds[128]s[20]dddd",dbid,model,vowner,posx,posy,posz,posa,vcolor1,vcolor2,vpaintjob,vmod,vplate,vlock,vgps,vassi);
    	c = AddStaticVehicleEx(model,posx,posy,posz,posa,vcolor1,vcolor2,-1);
		printf("%d",c);
   		PVehicles[c][pvehidDB] = dbid; PVehicles[c][pvehid] = c; PVehicles[c][pmodelid] = model; PVehicles[c][powner] = vowner;
   		PVehicles[c][pposx] = posx; PVehicles[c][pposy] = posy;  PVehicles[c][pposz] = posz;  PVehicles[c][pposa] = posa;
    	PVehicles[c][pcolor1] = vcolor1;  PVehicles[c][pcolor2] = vcolor2;  PVehicles[c][pmod] = vmod;  PVehicles[c][pplate] = vplate;
		PVehicles[c][plock] = vlock; PVehicles[c][pgas] = vgas; PVehicles[c][pgps] = vgps; PVehicles[c][passi] = vassi;
		PVehicles[c][ppaintjob] = vpaintjob;
		if (vpaintjob != 20) {ChangeVehiclePaintjob(c,vpaintjob);}
		SendClientMessageEx(playerid,COLOR_ALERT,"%s",c);
		printf("|> E' stato creato un veicolo di: %s. Con ID: %d",PlayerName(playerid),c);
		loaded++;
	}
	printf("|> Sono stati caricati i %d veicoli di %s",loaded,PlayerName(playerid));
	mysql_free_result();
}
I use the mysql plugin of StrikenKid. But why this don't work and don't load my vehicles?

Very Thanks to all xpeppe
Reply
#2

Post down what the printf says.. or at least.. one of them.. no need to release all the sensitive information. It would be good to know. Though I've experienced many problems myself with StrickenKid's plugin.. until I moved to G-StylezZz.. for some reason everytime I fetch multiple lines from the database with StrickenKid's plugin.. the server crashes.
Reply
#3

OMG. The server print only: [22:15:25] 1|1|411|1675.02|1447.99|10.7886|0|6|6|20|100||P3PP 3|0|1|1
But this print only whith me. Whit another player it print:
[21:35:34] |> Sono stati caricati i 0 veicoli di Kevin_Gerosa
I'm not Kevin Gerosa, i'm Steve Bullet.
Reply
#4

I don't understand what you're saying.. :S

The printf seems to be fine as it prints out all the data. Don't see the problem with sscanf.. either
Reply
#5

Look carefully if sscanf line is correct. The mistake might be there.
Reply
#6

You are only declaring three f
pawn Код:
fff
But you want these coords:
pawn Код:
posx
posy
posz
posa
Which would be:
pawn Код:
ffff
Reply
#7

Also, I think the order is not right.

In the print line

Код:
[22:15:25] 1|1|411|1675.02|1447.99|10.7886|0|6|6|20|100||P3PP 3|0|1|1
I think model is 3rd, but in sscanf model is 2nd and vowner is 3rd.
Reply
#8

EDITED...
Reply
#9

Help Please:
I transform my code in:
Код:
public LoadPlayerVehicles(playerid)
{
	new data[1024],loaded,row;
	new c,a,dbid,model,vowner,Float:posx,Float:posy,Float:posz,Float:posa,vcolor1,vcolor2,vpaintjob,vmod[128],vplate[20],vlock,vgas,vgps,vassi;
	format(Query,sizeof(Query),"SELECT * FROM `uvehicles` WHERE `owner` = %d",PlayerInfo[playerid][pDatabaseID]);
	mysql_query(Query);
	mysql_store_result();
	row = mysql_num_rows();
	for(new i = 0; i < row; i++)
	{
	    mysql_fetch_row(data,"|"); // Creo stringa dati
	    printf("%s",data);
		// 1|1|411|1675.02|1447.99|10.7886|0.0000|6|6|20|100||P3PP3|0|1|1
        sscanf(data, "p<|>dddffffdddds[128]s[20]ddd",dbid,model,vowner,posx,posy,posz,posa,vcolor1,vcolor2,vpaintjob,vmod,vplate,vlock,vgps,vassi);
    	c = AddStaticVehicleEx(model,posx,posy,posz,posa,vcolor1,vcolor2,-1);
		printf("%d",c);
   		PVehicles[c][pvehidDB] = dbid; PVehicles[c][pvehid] = c; PVehicles[c][pmodelid] = model; PVehicles[c][powner] = vowner;
   		PVehicles[c][pposx] = posx; PVehicles[c][pposy] = posy;  PVehicles[c][pposz] = posz;  PVehicles[c][pposa] = posa;
    	PVehicles[c][pcolor1] = vcolor1;  PVehicles[c][pcolor2] = vcolor2;  PVehicles[c][pmod] = vmod;  PVehicles[c][pplate] = vplate;
		PVehicles[c][plock] = vlock; PVehicles[c][pgas] = vgas; PVehicles[c][pgps] = vgps; PVehicles[c][passi] = vassi;
		PVehicles[c][ppaintjob] = vpaintjob;
		if (vpaintjob != 20) {ChangeVehiclePaintjob(c,vpaintjob);}
		SendClientMessageEx(playerid,COLOR_ALERT,"%s",c);
		printf("|> E' stato creato un veicolo di: %s. Con ID: %d",PlayerName(playerid),c);
		loaded++;
	}
	printf("|> Sono stati caricati i %d veicoli di %s",loaded,PlayerName(playerid));
	mysql_free_result();
}
But the vehicle don't Spawn why?
In the console was print:
Quote:

1|1|411|1675.02|1447.99|10.7886|0|6|6|20|100|0|P3P P3|0|1|1
sscanf warning: Format specifier does not match parameter count.

Thanks All
Reply
#10

UP!UP!UP!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)