SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 21/11/2010, 08:13 PM   #1
xpeppe
Little Clucker
 
Join Date: Jan 2010
Posts: 17
Reputation: 0
Default Create Vehicle with wrong ID

Hi all,
My problem is that: I user 2 function to load vehicles from Mysql Database. The first function it's work perfectly but the second not.
The first Function:
Code:
public LoadFactionVehicles()
{
	new row,data[1024];
	new x,dbid,model,Float:posx,Float:posy,Float:posz,Float:posa,faction,job,type,vcolor1,vcolor2,vplate[20];
	Query = "SELECT * FROM `fvehicles`";
	mysql_query(Query);
	mysql_store_result();
	row = mysql_num_rows();
	if (row > 0)
	{
        while(mysql_fetch_row(data))
        {
            	sscanf(data, "p<|>ddffffddddds[20]",dbid,model,posx,posy,posz,posa,faction,job,type,vcolor1,vcolor2,vplate);
    			x = AddStaticVehicleEx(model,posx,posy,posz,posa,vcolor1,vcolor2,-1);
    			FVehicles[x][fvehidDB] = dbid; FVehicles[x][fvehid] = x; FVehicles[x][fmodelid] = model;
     			FVehicles[x][fposx] = posx; FVehicles[x][fposy] = posy;  FVehicles[x][fposz] = posz;  FVehicles[x][fposa] = posa;
        		FVehicles[x][ffaction] = faction; FVehicles[x][fjob] = job;  FVehicles[x][fvehtype] = type;
        		FVehicles[x][fcolor1] = vcolor1;  FVehicles[x][fcolor2] = vcolor2;  FVehicles[x][fplate] = vplate;
		}
	}
	mysql_free_result();
}
And it load 2 vehicle because in the DB there are 2 vehicle saved.

The Second fuction this:
Code:
public LoadPlayerVehicles(playerid)
{
	new data[1024],dato[128],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();
	if (row > 0)
	{
        while(mysql_fetch_row(data))
        {
	    	//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,vowner,model,posx,posy,posz,posa,vcolor1,vcolor2,vpaintjob,vgas,vmod,vplate,vlock,vgps,vassi);
			//
			mysql_fetch_field("owner",dato); vowner = strval(dato);
			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);
			printf("Owner: %d",PVehicles[c][powner]);
			loaded++;
		}
	}
	printf("|> Sono stati caricati i %d veicoli di %s",loaded,PlayerName(playerid));
	mysql_free_result();
}
It work partial because he says the id of vehicle created is 6, but it not really create the vehicle with that id. But with the ID: 3.
It exaclty because it before create only 2 vehicle.
The problem is: Why it save the vehicle data in the array as the id is 6?

Thanks to all
xpeppe is offline  
Old 22/11/2010, 04:02 PM   #2
xpeppe
Little Clucker
 
Join Date: Jan 2010
Posts: 17
Reputation: 0
Default Re: Create Vehicle with wrong ID

When i create vehicle with the second function it start with the Id from 6 why? Help Please
xpeppe is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Vehicle Sascha Help Archive 7 23/06/2010 02:45 PM
how do i create a random vehicle? please help... FujiNNN Help Archive 12 13/03/2010 01:49 AM
Create a vehicle without respawn Rauminator Help Archive 2 03/02/2010 07:27 PM
[Help]Can't create vehicle SHADOW785 Help Archive 16 18/10/2009 09:01 AM
How to convert the vehicle lists to Create vehicle for each line Gabe713 Help Archive 1 05/10/2009 05:12 PM


All times are GMT. The time now is 09:21 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.