OnVehicleDeath - Getting vehicle killer
#1

I have a kind of an issue here... I'm trying to get the vehicle killer - the problem is, the killer is always in a car. (Derby server) My question is: how to get that driver/killer who pushed/exploded someone in the water or someone in another vehicle ?

Using OnVehicleDeath don't work.


pawn Код:
#define Loop(%0,%1) for(new %0 = 0; %0 < %1; %0++)

public OnVehicleDeath(vehicleid, killerid)
{
    new string[128];
    if (killerid != GetVehicleDriver(vehicleid) && (GetVehicleDriver(vehicleid) != INVALID_PLAYER_ID || killerid != INVALID_PLAYER_ID))
    {
        format(string, sizeof(string), "[KILL] - %s was killed by %s.", PlayerName(GetVehicleDriver(vehicleid)), PlayerName(killerid));
        SendClientMessageToAll(COLOR_RED,string);

    }
    return 1;
}

stock GetVehicleDriver(vehicleid)
{
    new vehicleDriver = INVALID_PLAYER_ID;

    Loop(i,MAX_PLAYERS)
    {
        if(IsPlayerConnected(i))
        {
            if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
            {
                if(GetPlayerVehicleID(i) == vehicleid) vehicleDriver = i; break;
            }
        }
    }
    return vehicleDriver;
}
99% i get this:
Quote:

[14:54:18] [KILL] - was killed by person1.

How can the driver be the killer anyway ?!
Reply
#2

I've been waititing since 2007 for this to be supported by SA-MP. Perhaps in 0.4.
Reply
#3

You could try code it with OnVehicleDamageStatusUpdate.

Like when a players vehicle gets damaged, store the closests players id, then on vehicle death the last id stored for who damaged that vehicle is declared the killer of the vehicle.
Reply
#4

That is only called for visual damage. Players will only visually damage a vehicle if they crash in to them. It won't do anything for weapons.

It would actually be very possible to script this using keys, camera vectors and OPU or a timer, but not exactly straightforward or reliable.
Reply
#5

There really is no way of knowing who destroyed a vehicle. You can make a (pretty accurate) guess though. For a dery server, try contstantly storing the last player to be closest to the player who died -- in 80% of the cases this player was the one that caused the explosion/push. When the player then dies, you can easily see who was the killer.

Native support would be nice though.
Reply
#6

You could probably loop and see GetVehicleHealth repeatedly and subtract the health from the damage and if it's below 0 or 0, get the closest player nearby in a vehicle. It will be inaccurate, but, okie dokie ! (Use something like OnPlayerVehicleDamage)
Reply
#7

Quote:
Originally Posted by MP2
Посмотреть сообщение
That is only called for visual damage. Players will only visually damage a vehicle if they crash in to them. It won't do anything for weapons.

It would actually be very possible to script this using keys, camera vectors and OPU or a timer, but not exactly straightforward or reliable.
Woah, don't make it to hard with keys, vectors, timers etc The less code, the better :3

Quote:
Originally Posted by Sinner
Посмотреть сообщение
There really is no way of knowing who destroyed a vehicle. You can make a (pretty accurate) guess though. For a dery server, try contstantly storing the last player to be closest to the player who died -- in 80% of the cases this player was the one that caused the explosion/push. When the player then dies, you can easily see who was the killer.

Native support would be nice though.
Hmm, not a bad idea...

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
You could probably loop and see GetVehicleHealth repeatedly and subtract the health from the damage and if it's below 0 or 0, get the closest player nearby in a vehicle. It will be inaccurate, but, okie dokie ! (Use something like OnPlayerVehicleDamage)
I think this is slower than Sinners idea.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)