Skip to content
Nexius edited this page Oct 14, 2024 · 46 revisions

Variant 1: base check

const VehicleDestroyed = 136;

IRPC:VehicleDestroyed(playerid, BitStream:bs)
{
    new vehicleid;

    BS_ReadUint16(bs, vehicleid);

    if (GetVehicleModel(vehicleid) < 400) {
        return 0;
    }

    return OnVehicleRequestDeath(vehicleid, playerid);
}

forward OnVehicleRequestDeath(vehicleid, killerid);
public OnVehicleRequestDeath(vehicleid, killerid)
{
    new Float:health;

    GetVehicleHealth(vehicleid, health);

    if (health >= 250.0) {
        return 0;
    }

    return 1;
}

Variant 2: check vehicle in water (ColAndreas required)

const VehicleDestroyed = 136;

IRPC:VehicleDestroyed(playerid, BitStream:bs)
{
    new vehicleid;

    BS_ReadUint16(bs, vehicleid);

    if (GetVehicleModel(vehicleid) < 400) {
        return 0;
    }

    return OnVehicleRequestDeath(vehicleid, playerid);
}

forward OnVehicleRequestDeath(vehicleid, killerid);
public OnVehicleRequestDeath(vehicleid, killerid)
{
    new Float:health, Float:depth, Float:vehicledepth;

    GetVehicleHealth(vehicleid, health);

    if (health >= 250.0
        && !CA_IsVehicleInWater(vehicleid, depth, vehicledepth)
    ) {
        return 0;
    }

    return 1;
}