Despawn more than 1 vehicle
#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


Messages In This Thread
Despawn more than 1 vehicle - by MarianImmortalGod - 01.04.2018, 16:30
Re: Despawn more than 1 vehicle - by Maxandmov - 02.04.2018, 10:24
Re: Despawn more than 1 vehicle - by MarianImmortalGod - 02.04.2018, 17:35

Forum Jump:


Users browsing this thread: 1 Guest(s)