SA-MP Forums Archive
Despawn car - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Despawn car (/showthread.php?tid=651968)



Despawn car - MarianImmortalGod - 31.03.2018

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[cData[PCarID]][pcStatus] = 0;
			pcUpdate(cData[PCarID], pcStatus);

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