Make OnPlayerGiveDamage be called from vehicles
#1

Just like 0.3z adds as a new feature that OnPlayerGiveDamage is called when you hit NPC's, this callback should also be called when you hit someone with the guns of armed vehicles (like Rustler, Seasparrow, RC Baron, Hunter and Predator), and also when you hit him directly with your vehicle and with helicopter blades. As far as I know, the only situation in which your client calls OnPlayerGiveDamage while driving a vehicle is when driveby shooting.
I think my suggestion should be perfectly possible because you can see in your screen the animation of the other player being hit and dropping blood.
Reply
#2

I fully support your suggestion. This is yet another 'hole' in the SA:MP callback system that can confuse the hell out of people.
Reply
#3

Can't you use ...WeaponShot for this?
Reply
#4

with OnPlayerWeaponShot you can detect it and can do, for example, allow players to destroy vehicles without drivers.


pawn Код:
new Float:armaDano;

// Weapons damage, taken from sa-mp wiki.
armasDano[22] = 25;
armasDano[23] = 40;
armasDano[24] = 70;
armasDano[25] = 30;
armasDano[26] = 30;
armasDano[27] = 25;
armasDano[28] = 20;
armasDano[29] = 25;
armasDano[30] = 30;
armasDano[31] = 30;
armasDano[32] = 20;
armasDano[33] = 75;
armasDano[34] = 125;
armasDano[38] = 140;

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    switch(hittype) {
        case 2: { // When a vehicle hit happens
            new Float:veiculoHp;
            GetVehicleHealth(hitid, veiculoHp);

            if(armasDano[weaponid] > 0 && IsVehicleEmpty(hitid)) {
                new Float:novoHp = veiculoHp - armasDano[weaponid];

                // It is not good to let vehicles explode with nobody driving it because of desync problems.
                if(novoHp > 251) {
                    SetVehicleHealth(hitid, novoHp);
                }
            }
        }
    }
}

stock IsVehicleEmpty(vehicleid)
{
  for(new i; i < MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerVehicleID(i) == vehicleid) return 0;
  }
  return 1;
}
Reply
#5

Quote:
Originally Posted by OKStyle
Посмотреть сообщение
Can't you use ...WeaponShot for this?
No, that callback is not called when you drive vehicles.

Quote:
Originally Posted by Mandrakke
Посмотреть сообщение
with OnPlayerWeaponShot you can detect it and can do, for example, allow players to destroy vehicles without drivers.
Thanks for the code but that's a different matter.
Reply
#6

Or, the alternative, let "OnPlayerWeaponShot" work when players are in a vehicle.
Reply
#7

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Or, the alternative, let "OnPlayerWeaponShot" work when players are in a vehicle.
That would be the best thing, and it has already been reported here, but I think there's a reason why that won't be possible.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)