OnVehicleDeath not getting called for unoccupied vehicles? - 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: OnVehicleDeath not getting called for unoccupied vehicles? (
/showthread.php?tid=584875)
OnVehicleDeath not getting called for unoccupied vehicles? -
Sjn - 08.08.2015
I am trying to delete the vehicle if the player has no insurance bought for their vehicles. The strange bug i found here is; if the vehicle is loaded from the database and no one drove it and it somehow gets destroyed by flipping, sinking in water or however, OnVehicleDeath callback is not getting called for it. But if there's a driver driving that vehicle and they destroys it by ramming or however, callback is called and the vehicle is getting deleted.
Is it a default bug from samp? Is there any other ways to fix it?
PHP код:
public OnVehicleDeath(vehicleid)
{
if (vInfo[vehicleid][v_Owned] == 1)
{
if (vInfo[vehicleid][v_HouseID] != 0 && hInfo[vInfo[vehicleid][v_HouseID]][h_Insur] == 0)
DeleteOwnedVehicle(vehicleid);
}
return 1;
}
DeleteOwnedVehicle(vid)
{
new
query[100];
mysql_format(mysql, query, sizeof(query), "DELETE FROM `vehicles` WHERE `id`='%d'", vInfo[vid][v_ID]);
mysql_tquery(mysql, query, "", "");
new
houseid,
idx;
houseid = vInfo[vid][v_HouseID];
if (houseid != 0)
{
for (new i; i < MAX_PVEH; ++i)
{
if (hInfo[houseid][h_pVehs][i] == vid)
{
idx = i;
break;
}
}
hInfo[houseid][h_pVehs][idx] = 0;
}
DestroyVehicle(vid);
if (IsValidDynamic3DTextLabel(vInfo[vid][v_OwnerText]))
DestroyDynamic3DTextLabel(vInfo[vid][v_OwnerText]);
for (new i; i < _: E_VehicleData; ++i)
vInfo[vid][E_VehicleData: i] = 0;
}
Re: OnVehicleDeath not getting called for unoccupied vehicles? -
Sjn - 09.08.2015
/Bump
Re: OnVehicleDeath not getting called for unoccupied vehicles? -
Abagail - 09.08.2015
If the vehicle hasn't been occupied at all since the server started then no it won't be called though it should be called even if there's no driver currently but has been occupied at least once.
Re: OnVehicleDeath not getting called for unoccupied vehicles? -
Sjn - 10.08.2015
Oh ok, thanks for replying.