OnPlayerDeath and Carmods
#1

I have found two bugs, and could not found them to be listed on the forum yet.

The first one is the biggest problem for me at the moment (I have created a workaround at the moment)

On our RP server it is not allowed for players to kill each other without a decent reason, therefor players
will get jailed. There are also some diseases on our server where people can lose health from or even die,
when they don't get med's on time.

This doesn't seem to be a big deal, BUT combining these two:

Let's say I accidentally punched one of the players, and about 30 minutes later he dies due to a scripted health
loss like this one (I know its not a clean code but just as an example):
pawn Код:
//In case when a player eats food that is to old or spoiled
   new Float:FoodHealth;
   GetPlayerHealth(playerid, FoodHealth);
   FoodHealth = FoodHealth - 45.0;
   SetPlayerHealth(playerid, FoodHealth);
Then the server/client still reports that the death was caused by me.

I created a work around with a function called 'NSetPlayerHealth(playerid, Float:health);' where I
set a variable that registers that the damage came from somewhere scripted (like not eating, decease, car crash etc)
And when a player causes the damage I set that variable on -1 (at OnPlayerTakeDamage).

But this was a way where players could kill them self by crashing into a wall after someone hit them and
causing other people to get jailed unfairly for a murder.
Now I know this is an rare use of reading the OnPlayerDeath and using SetPlayerHealth, but i do think this
should be considered as a bug?

Second bug:
Some cars do not spawn their side-skirts properly, meaning that if a car is saved with side-skirt that the
car has to be re spawned to show the side-skirts and sometimes they still disappear when a player
enters a building/virtualworld en then returns to his vehicle.

Hope the information provided here is complete enough, if just replay or PM me if you need more details.
Reply
#2

Second Bug: This is actually a commonly known bug. There has always been an issue with it.
Reply
#3

Quote:
Originally Posted by Akira297
Посмотреть сообщение
Second Bug: This is actually a commonly known bug. There has always been an issue with it.
Oke, thanks for the info, to be honest I've searched my guts out for the first bug, and "not" so much for the
first one, but did not find it so fast though.

Atleast glad to know I'm not the only one (tried everything to make a workaround that hadn't to much
disadvantages, but still could not think of one).

Anyone else who experienced problems with the first bug I mentioned?
I know for sure that it is not in my script because it is easily repeatable by just creating a new GM with a simple
command like '/hurtme' (in which you take away 50.0 health), just create a simple [Player] Killer [Player] message
in the routine 'OnPlayerDeath' (so you can see who gets the kill).

Then enter with two players, let player 2 hit player 1 ONCE! and then let player 1 execute the /hurtme until he
dies. You will see that the death is counted for player 2.
Reply
#4

it sounds like a problem within your OnPlayerDeath
Reply
#5

Quote:
Originally Posted by cessil
Посмотреть сообщение
it sounds like a problem within your OnPlayerDeath
No just like is said you can easily replicate it, by just creating an empty gamemode.
It is a SA-MP problem when you combine your own scripted damage using SetPlayerHealth
and with the default in game OnPlayerTake damage.

I even gave an example how you can replicate the problem.

I've already made sure that it isn't my own script, always do multiple checks before I do
a bug report, I'm a certified .NET Developer so I know how annoying and time consuming
it can be when someone reports a product or module bug when the bug is in the users
section instead of the product.

Thanks for your input anyway, i hope this problem can be figured out

For now I don't have any problems with it anymore because I let the server register if
the player, the server or a other player inflicts the damage by setting a reference to a player (playerid),
to the server/scripted damage (-16) and when a player inflicted the damage himself (-32).
And I don't have the problem anymore.
Reply
#6

The first is a known bug - when a player takes damage by someone else and then SetPlayerHealth is used to kill the player, the guy who gave damage before will be the killer. I don't think you can prevent it.
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
The first is a known bug - when a player takes damage by someone else and then SetPlayerHealth is used to kill the player, the guy who gave damage before will be the killer. I don't think you can prevent it.
Ok thank you for confirming this for me ,

There IS a way to prevent this (I've created a work-around to fix this)
It will be a little bit hard to convert this to a snippet but if there is no known fix for this i could try to convert my
solution for this. If there are people that need a (temporarily) workaround for this problem please post it
here and I will try to convert my workaround to a more 'universal' fix
Reply
#8

You're right.

I was looking some tests I have done in the past and it seems that using your on OnPlayerDeath(Ex) callback with OnPlayerTakeDamage's help and a custom SetPlayerHealth(Ex) to control whether you kill the player, you can pass the killerid as an INVALID_PLAYER_ID.
Reply
#9

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
You're right.

I was looking some tests I have done in the past and it seems that using your on OnPlayerDeath(Ex) callback with OnPlayerTakeDamage's help and a custom SetPlayerHealth(Ex) to control whether you kill the player, you can pass the killerid as an INVALID_PLAYER_ID.
I think this could be solved easily in the SA-MP server/client (don't know where it is managed of-course, and
I don't know how the source looks of-course) But i think it would be relative easily by just (re)setting the
killer/IssuerID to INVALID_PLAYER_ID when the callback SetPlayerHealth is used.

Yeah I do understand that there are MINIMAL chances that when someone shoots someone EXACTLY before
a SetPlayerHealth, it would not count as a kill for that player. But those chances are minimal and causing less
inconvenience than the current situation.

Thanks again for confirming my solution
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)