Skip to content

[BEHAVIOUR DIFFERENCE] OnPlayerGiveDamageActor doesn't get called if amount is equal to 0 #761

Closed

Description

@ReshiramZekrom1

Describe the bug
While this seems to be right, SA-MP's OnPlayerGiveDamageActor actually got called if the amount was equal to 0 and afaik it was the case in one particular case: when you kill the actor from behind with the knife.
In this scenario, the callback gets called actually thrice: the first time as soon as you strike the hit (amount is 0), the second and third times during the ped dying animation (amount is 5555.549804 in both).
On open.mp this check prevents the first call and, while it's not a real issue per se, I found the behaviour on SA-MP more useful at least for my case.
I have a scripted pedestrian system made with actors that have a walking animation. And curiously enough, if you try to kill them from behind with the knife ( while the actor is performing the animation ) the callback gets triggered only once (right after the player stabs the actor and registers an amount of 0). Infact, on open.mp I can't kill instantly kill peds with the knife anymore since the callback doesn't get triggered in this way. I can probably find a workaround by using OnPlayerUpdate and checking the player's holding weapon, if its close enough to an actor, pressing the right buttons and if it's exactly behind the actor but it can't be exactly right since there are no ways to know the exact actor's position if an animation is running since you just get the spawn position with GetActorPos function. I use a estimate pos already in this system but it's not really accurate of course.

To Reproduce
https://pastebin.com/UCBpfYnb

Expected behavior
OnPlayerGiveDamageActor should get called as soon as you stab the actor from behind with the knife.

Screenshots and/or logs
This is the SA-MP Behaviour:
sa-mp-010

This is the open.mp Behaviour (current commit):
sa-mp-011

And this is the open.mp build I've build myself with the <= 0 replaced by < 0. Tried to kill the actor while I was playing a walking animation. As you can see, the callback gets called just once in this case.
sa-mp-012

Commit hash in master
2037a95

Activity

  1. added
    bug
    on Nov 5, 2023
  2. added a commit that references this issue on Nov 5, 2023
  3. r4sheed commented on Nov 7, 2023

    @r4sheed

    The callback should not be called with amount of 0. How you even can damage someone with value of 0? That’s just stupid. The reason is the bad knife sync which should be fixed on client side. I recommend to restrict using a knife as a weapon but use as a custom one (for example as an attachment), then make your own action for doing that instant kills.

  4. NexiusTailer commented on Nov 7, 2023

    @NexiusTailer
    Contributor

    I recommend to restrict using a knife as a weapon but use as a custom one (for example as an attachment), then make your own action for doing that instant kills.

    Such kludges shouldn't replace standard game logic imo.

    The callback should not be called with amount of 0. How you even can damage someone with value of 0? That’s just stupid.

    The same with regular OnPlayerGiveDamage where this behaviour was for years in samp server, thus some scripts are still dependent on it. See #104 in the old repo. This also can be considered as an established feature that scripts rely on.

  5. ReshiramZekrom1 commented on Nov 7, 2023

    @ReshiramZekrom1
    ContributorAuthor

    The callback should not be called with amount of 0. How you even can damage someone with value of 0? That’s just stupid. The reason is the bad knife sync which should be fixed on client side. I recommend to restrict using a knife as a weapon but use as a custom one (for example as an attachment), then make your own action for doing that instant kills.

    Actually OnPlayerGiveDamage and OnPlayerTakeDamage are called when the amount is 0 even on open.mp:

    if (onPlayerGiveTakeDamageRPC.Damage < 0.0f)

    It's just the OnPlayerGiveDamageActor which acts differently

  6. r4sheed commented on Nov 7, 2023

    @r4sheed

    I recommend to restrict using a knife as a weapon but use as a custom one (for example as an attachment), then make your own action for doing that instant kills.

    Such kludges shouldn't replace standard game logic imo.

    Yes you’re right, it shouldn't. But it not works as intended.

  7. NexiusTailer commented on Nov 7, 2023

    @NexiusTailer
    Contributor

    I recommend to restrict using a knife as a weapon but use as a custom one (for example as an attachment), then make your own action for doing that instant kills.

    Such kludges shouldn't replace standard game logic imo.

    Yes you’re right, it shouldn't. But it not works as intended.

    Well, ofc it would be cool to fix this on clientside when this will be possible (when there will be a clientside part), but it's better for now to keep the behaviour the same like OnPlayerGiveDamage here, and like it's in samp server. Some can say "no let's break it like the other stuff we already did just to not feel imaginary pain that it's working not like we expect", and change OnPlayerGiveDamage instead to block 0.0 damage. But the result will be another bunch of broken samp scripts and no real cause why it was done.

  8. Mergevos commented on Nov 7, 2023

    @Mergevos

    When we will stop postponing new features and fixing behaviours because of SAMP compatibility?

  9. Alasnkz commented on Nov 7, 2023

    @Alasnkz
    Member

    When we will stop postponing new features and fixing behaviours because of SAMP compatibility?

    There are always little oversights that happen. None of these are actual breaking. None of these are the result of adding things (that should be added in the first place). Especially when this was just reported, you had multiple months (a year by now) to discover this but nobody else did, that shows how much of a breaking thing it is, (i.e. not).

  10. added a commit that references this issue on Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugnightly

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions