OnPlayerWeaponShoot + Vehicle pop tire
#1

I've been trying to work this out, but shit is killing me. I am giving this code to the other people, that might do something with it. Feel free to do anything.

pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    switch(hittype)
    {
        case BULLET_HIT_TYPE_VEHICLE:
        {
            static Float:ShootX, Float:ShootY, Float:Offset[6],
                   panels, doors, lights, tires;
                   
            GetVehicleModelInfo(GetVehicleModel(hitid), VEHICLE_MODEL_INFO_WHEELSFRONT, Offset[0], Offset[1], Offset[2]);
            GetVehicleModelInfo(GetVehicleModel(hitid), VEHICLE_MODEL_INFO_WHEELSREAR,  Offset[3], Offset[4], Offset[5]);

            for (new Float:i = 0.0; i < 0.5; i += 0.1)
            {
                ShootX = floatadd(Offset[0], i);
                ShootY = floatadd(Offset[1], i);
               
                // Front left.
                if((fX <= ShootX && (fX >= -1.253 && fX <= -1.128)) && (fY <= ShootY && (fY >= 1.129 && fY <= 1.710)))
                {
                    GetVehicleDamageStatus(hitid, panels, doors, lights, tires);
                    UpdateVehicleDamageStatus(hitid, panels, doors, lights, 8);
                    break;
                }
            }
        }
    }
    return 1;
}
Probably I can't work this out, because there's some better way to do it, but I never had trigonometry (because I left my country, and they didn't teached me in UK yet). I suppose, that trigonometry might help here, but I am not sure. Do whatever you want with this code, I'll just leave it here.

(code works only on certain vehicles, not all and only front left tire)

Also, here's an extra code, which I've modified from different thread, which I've found.

pawn Код:
CMD:test(playerid, params[])
{
    // Get vehicle position
    new Float:x, Float:y, Float:z;
    GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);

    new Float:x2, Float:y2;
    GetVehiclePos(GetPlayerVehicleID(playerid), x2, y2, z);

    new Float:x3, Float:y3;
    GetVehiclePos(GetPlayerVehicleID(playerid), x3, y3, z);

    new Float:x4, Float:y4;
    GetVehiclePos(GetPlayerVehicleID(playerid), x4, y4, z);

    // Get vehicle angle
    new Float:vehAngle;
    GetVehicleZAngle(GetPlayerVehicleID(playerid), vehAngle);

    // Get Offsets
    new Float:wheelOffset[3];
    GetVehicleModelInfo(GetVehicleModel(GetPlayerVehicleID(playerid), VEHICLE_MODEL_INFO_WHEELSFRONT, wheelOffset[0], wheelOffset[1], wheelOffset[2]);

    // Front right.
    x += (floatcos(vehAngle, degrees) * wheelOffset[0]) - (floatsin(vehAngle, degrees) * wheelOffset[1]);
    y += (floatsin(vehAngle, degrees) * wheelOffset[0]) + (floatcos(vehAngle, degrees) * wheelOffset[1]);

    // Rear left
    x2 -= (floatcos(vehAngle, degrees) * wheelOffset[0]) - (floatsin(vehAngle, degrees) * wheelOffset[1]);
    y2 -= (floatsin(vehAngle, degrees) * wheelOffset[0]) + (floatcos(vehAngle, degrees) * wheelOffset[1]);

    // Rear right.
    x3 -= (floatcos(vehAngle, degrees) * wheelOffset[0]) - (floatsin(vehAngle, degrees) * wheelOffset[1]);
    y3 += (floatsin(vehAngle, degrees) * wheelOffset[0]) + (floatcos(vehAngle, degrees) * wheelOffset[1]);

    // Left front.
    x4 += (floatcos(vehAngle, degrees) * wheelOffset[0]) - (floatsin(vehAngle, degrees) * wheelOffset[1]);
    y4 -= (floatsin(vehAngle, degrees) * wheelOffset[0]) + (floatcos(vehAngle, degrees) * wheelOffset[1]);
    return 1;
}
I'm out from here, before my mind gonna blow up.
Reply
#2

I'm trying this too ...i see you are doing better anyway but lets keep this topic alive cuz its very interisting and cool if it would work

BTW when i broke (killed) an unoccupied vehicle it respawns with vehicle health 0 :S [EDIT]: o sorry it seems to be a common bug
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)