OnPlayerDeath Weird Problem [REP+]
#1

Hello,

I faced a very weird problem on my server, OnPlayerDeath callback doesn't return correct killerid and reason I tried to debug it and every statement is called I have also putted a print message and got the following results

Code
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	Server(playerid, "OnPlayerDeathCalled");
	printf("playerid: %d killerid: %d reason: %d", playerid, killerid, reason);
        return 1;
}
Output:
Код:
[04:07:49] playerid: 0 killerid: 65535 reason: 255
That printed when my friend killed me^

I tried to run nativechecker and crashdetect but nothing printed, also I don't think that code is needed because I debugged every statement and everything worked properly, any help would very appreciated


EDIT:
Problem is fixed, fix is here
Reply
#2

I think you need to check if killerid is valid.
Код:
if(killerid != INVALID_PLAYER_ID)
{
//your stuff
}
Reply
#3

Quote:
Originally Posted by lucamsx
Посмотреть сообщение
I think you need to check if killerid is valid.
Код:
if(killerid != INVALID_PLAYER_ID)
{
//your stuff
}
65535 means you killed yourself, OnPlayerDeath returns 65535 when its called even if someone else killed me, also I have this check for killerid, SendDeathMessage already checks for it, so it's not needed
Reply
#4

But theres no need of usage of invalid id check in SendDeathMessage. 65535 is a valid parameter in this function.
Maybe try putting this check somewhere else?
Reply
#5

Quote:
Originally Posted by lucamsx
Посмотреть сообщение
But theres no need of usage of invalid id check in SendDeathMessage. 65535 is a valid parameter in this function.
Maybe try putting this check somewhere else?
It means that player has killed his self, I think that there is a problem with fake kill system, I am looking for it now


EDIT: problem still exists it wasn't fake kill system
Reply
#6

Quote:
Originally Posted by SecretBoss
Посмотреть сообщение
Hello,

I faced a very weird problem on my server, OnPlayerDeath callback doesn't return correct killerid and reason I tried to debug it and every statement is called I have also putted a print message and got the following results

Code
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	Server(playerid, "OnPlayerDeathCalled");
	printf("playerid: %d killerid: %d reason: %d", playerid, killerid, reason);
        return 1;
}
Output:
Код:
[04:07:49] playerid: 0 killerid: 65535 reason: 255
That printed when my friend killed me^

I tried to run nativechecker and crashdetect but nothing printed, also I don't think that code is needed because I debugged every statement and everything worked properly, any help would very appreciated
Got a custom damage system ? Probably yes, that causes it, you set the player's HP to 0, he dies by your hand (code) not the default sa-mp damage therefore it's a suicide.
You should make checks under your custom damage.
Reply
#7

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
Got a custom damage system ? Probably yes, that causes it, you set the player's HP to 0, he dies by your hand (code) not the default sa-mp damage therefore it's a suicide.
You should make checks under your custom damage.
You are right, I added some checks but I can't get player's reaason
Reply
#8

Here is a suggestion, When you kill him with setting his HP to 0, Call the Onplayerdeath yourself and trash the default OnPlayerDeath

Edit: I had the same problem and found the solution before, but was too lazy to add it to my script, I went ahead and added it right now, it should work in theory (Don't really have anyone around to test it right now, but you go ahead and test now)
use this for your custom damage deaths CallLocalFunction("OnPlayerDeath","iii",playerid,i ssuerid,weaponid);
and this in first line of OnPlayerDeath if(reason==255) return 1;
Reply
#9

I have same problem, when I kill my friend with m4, reason of onplayerdeath is 255.
Reply
#10

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
Here is a suggestion, When you kill him with setting his HP to 0, Call the Onplayerdeath yourself and trash the default OnPlayerDeath (so trash it whenever it's reason 255)
I use it on OnPlayerTakeDamage, I can take issuerid as the killerid and playerid, what about for reason, it will return invalid reason (255) something I don't want?

Nice idea I will test it now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)