Despawn more than 1 vehicle
#1

Hey guys i have a personal vehicle system but i have a problem with the cars, when a player
disconnect's and his cars are spawned and let's say he has more than 1 car only first
car will despawn(destroyed) but the other one wont any idea what is wrong with this
script ?

Код HTML:
function DespawnPlayerVehicle(playerid)
{
	new gQuery[85];
    mysql_format(handle, gQuery, sizeof(gQuery),  "SELECT * FROM `personalcars` WHERE `Owner` = '%s'", GetName(playerid));
    new Cache:r = mysql_query(handle, gQuery);
    for(new i; i < cache_num_rows(); i++)
	{
	    new dbid = cache_get_value_name_int(i, "ID", CarInfo[playerid][pcID]);
   		new PCarID = VEHICLEFROMDB(dbid);
   		if(PCarID)
   		{
			CarInfo[vDBID[PCarID]][pcStatus] = 0;
			pcUpdate(vDBID[PCarID], pcStatus);

			DestroyVehicle(PCarID);
			vDBID[PCarID] = 0;
   		}
 	}
 	cache_delete®;
}
Код HTML:
stock VEHICLEFROMDB(dbid)
{
    for(new i = 1; i <= GetVehiclePoolSize(); i++)
	{
	    if(vDBID[i] == dbid) return i;
	}
	return 0;
}
Reply
#2

Код:
stock VEHICLEFROMDB(dbid)
{
    for(new i = 1; i <= GetVehiclePoolSize(); i++)
	{
	    if(vDBID[i] == dbid) return i;
	}
	return 0;
}
As far as I see you return first vehicle you find.
I had rather do it somehow like that (I might be wrong in what I coded, but I hope you get the general idea)

Код:
function DespawnPlayerVehicle(playerid)
{
	new gQuery[85];
    mysql_format(handle, gQuery, sizeof(gQuery),  "SELECT * FROM `personalcars` WHERE `Owner` = '%s'", GetName(playerid));
    new Cache:r = mysql_query(handle, gQuery);
    for(new i; i < cache_num_rows(); i++)
	{
	    new dbid = cache_get_value_name_int(i, "ID", CarInfo[playerid][pcID]);
   		for(new i = 1; i <= GetVehiclePoolSize(); i++)
	        {
	            if(vDBID[i] == dbid)
                    {
   		         if(PCarID)
   		         {
			    CarInfo[vDBID[PCarID]][pcStatus] = 0;
			    pcUpdate(vDBID[PCarID], pcStatus);

			    DestroyVehicle(PCarID);
			    vDBID[PCarID] = 0;
                          }
                    }
   		}
 	}
 	cache_delete®;
}
I mean, I have to cycle through every entry there. This stock, VehicleFromDB, returns first entry which fulfills the requirement, which means it's not quite suitable for your task.
Reply
#3

Nothing happens
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)