Killerid registration OnVehicleDeath
#1

So,

Been working on something that involves killing vehicles from inside vehicles (duh... airplanes).
Now I've noticed the default 'killerid' value in OnVehicleDeath and I tought; Yes, that's it, perfect! Until I started testing and killerid always returns 255. -.- (So I get it, this might be logical since gta sa(-mp) can't detect this .. ?)

BUT
I'm not willing to surrender! If anyone can come up with a good id of scripting this, please post it!
Own id's:
¤ GetClosestPlayer() with hp > 0 (ofcourse NOT 100% bug proof, since someone can fly-by and it will register a wrong id)
¤ The above combinated with key registration? wich player fired in the past seconds (but again not 100% bug proof)

Anyone with a better idea?

PS: yes, maybe this belongs in the script request thread or in sa-mp suggestion topic but let's just discuss this please?
Reply
#2

So you destroy the vehicle with SetVehicleHealth or something, and so it does not detect the correct player?
Reply
#3

In this case I kill one vehicle with another (e.g. killing rustler with rustler) and the killerid output is 255 since the rustler (victim) died of an explosion I guess.
Reply
#4

Look in a_samp:

pawn Код:
forward OnVehicleDeath(vehicleid, killerid);
There's already a "killerid" argument! (This is my a_samp. I don't know if yours have this too)
Reply
#5

Quote:
Originally Posted by [GF]Sasino97
Посмотреть сообщение
Look in a_samp:

pawn Код:
forward OnVehicleDeath(vehicleid, killerid);
There's already a "killerid" argument! (This is my a_samp. I don't know if yours have this too)
Dear [GF]Sasino97, please read and understand before posting. In the first post is mentioned that I know of this killerid argument. The only thing that is wrong is that this 'killerid' always returns 255 and therefor is useless to me.
Reply
#6

Quote:
Originally Posted by [GF]Sasino97
Посмотреть сообщение
Look in a_samp:

pawn Код:
forward OnVehicleDeath(vehicleid, killerid);
There's already a "killerid" argument! (This is my a_samp. I don't know if yours have this too)
And this one always is 255 in his case, as he said twice

Hm thats difficult then, you could use GetVehicleRotationQuat for the all vehicles in a loop, convert it to degrees, and check if it is facing at the killed vehicle, like a IsPlayerAimingAt function for vehicles. Not an easy solution, but if you also check if the fire key is pressed, you can be 99,9% sure it really is the killer.
Reply
#7

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
And this one always is 255 in his case, as he said twice

Hm thats difficult then, you could use GetVehicleRotationQuat for the all vehicles in a loop, convert it to degrees, and check if it is facing at the killed vehicle, like a IsPlayerAimingAt function for vehicles. Not an easy solution, but if you also check if the fire key is pressed, you can be 99,9% sure it really is the killer.
I love the way your thinking

Won't there just be an issue when let's say; 'Rustler fires upon other rustler until black smoke rises, then the attacking rustler flies of (flees the 'crime-scene') since he knows the vehicle (his victim rustler) will be death in seconds. Then when onvehicledeath is called the attacker is long gone and chances are he is no longer firing.

PS: posted yesterday in suggestions for future sa-mp versions
Quote:
Originally Posted by Rizard
Посмотреть сообщение
If possible:

OnPlayerDamageVehicle(playerid,vehicleid); //registration, when on foot OR when using a vehicle (rustler,tank,hydra,...) to create damage!
OnPlayerDestroyVehicle(playerid,vehicleid); //registration, even when the killer is in a weaponized vehicle (tank,hydra,hunter,rustler,seasparrow,...)
Reply
#8

Quote:
Originally Posted by Rizard
Посмотреть сообщение
Won't there just be an issue when let's say; 'Rustler fires upon other rustler until black smoke rises, then the attacking rustler flies of (flees the 'crime-scene') since he knows the vehicle (his victim rustler) will be death in seconds. Then when onvehicledeath is called the attacker is long gone and chances are he is no longer firing.
Hehe, right, that wont work correctly. This could be fixed by not only checking if a vehicle faces another one when it gets destroyed, but all the time, when a player fires. When a player in a weaponed vehicle presses the fire key, set up a timer that checks e.g. every 250ms if the vehicle faces another vehicle, and when the health of that attacked vehicle gets below a specific value, store the attacking player id in an array for all vehicle (to mark the vehicle as killed by that player). Then on OnVehicleDeath, check if that variable is set for the killed vehicle, and reset it at the end.
Ok, this is again more complex, and will use a higher amount of CPU, but this is the best solution i can think of spontaneously

(thats about a variation of a method i use to detect the killer of a player who killed him with fire of explosions, and not with the explosion itself, in one of my scripts )
Reply
#9

never mind
Reply
#10

K, sorry about the double post but just to make sure...

If I want to check if the attacking vehicle is aiming at the victim, they both need about the same VehicleRotation right? Or can those values be negative when they fly towards eachother?

Grts
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)