You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BEHAVIOUR DIFFERENCE] OnPlayerGiveDamageActor doesn't get called if amount is equal to 0 #761
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.
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:
This is the open.mp Behaviour (current commit):
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.
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.
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.
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:
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.
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.
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).
Activity
Update actors_main.cpp
r4sheed commentedon Nov 7, 2023
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.
NexiusTailer commentedon Nov 7, 2023
Such kludges shouldn't replace standard game logic imo.
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.
ReshiramZekrom1 commentedon Nov 7, 2023
Actually OnPlayerGiveDamage and OnPlayerTakeDamage are called when the amount is 0 even on open.mp:
open.mp/Server/Source/player_pool.hpp
Line 192 in 2037a95
It's just the OnPlayerGiveDamageActor which acts differently
r4sheed commentedon Nov 7, 2023
Yes you’re right, it shouldn't. But it not works as intended.
NexiusTailer commentedon Nov 7, 2023
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.
Mergevos commentedon Nov 7, 2023
When we will stop postponing new features and fixing behaviours because of SAMP compatibility?
Alasnkz commentedon Nov 7, 2023
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).
Update actors_main.cpp (#762)