SendDeathMessage problem
#1

I can't figure out how to make it show the suicide message

here is code that i have been trying to show if a player is suiciding but nothing shows up and my HUD is enabled

pawn Код:
if(killerid == playerid)
    {
       SendDeathMessage(playerid,playerid,53);
       return 1;
    }
Reply
#2

Your code is checking if killerid and playerid are the same. Observe the death list below.



You can see that for the first case (suicide), there's no killer for playerid, not even playerid itself. For nonexistent killers, you need to check if killerid is equal to INVALID_PLAYER_ID.
Reply
#3

Can you please code the fix for me?
Reply
#4

I told you everything you needed to solve your problem, even gave you an explanation rather than a line of code which would defeat the purpose of learning. You merely need to replace a single variable (playerid) with a macro (INVALID_PLAYER_ID).
Reply
#5

No, he needs to simply pass the parameters that are passed to OnPlayerDeath - like it says on the wiki - :

pawn Код:
SendDeathMessage(killerid, playerid, reason);
You don't need to check whether the killerid is valid or not for SendDeathMessage. INVALID_PLAYER_ID is a valid killerid (it means no killer - suicide).

You never need to check that playerid is valid. Obviously it's valid - someone died, calling OPD.
Reply
#6

I believe he wanted the death message reason to always be 53 for cases of suicide, hence why he needs to check if killerid is INVALID_PLAYER_ID.
Reply
#7

I wanted it to originally show the suicide death reasons and i already putted what MP2 said before i posted this thread

i said that i want only the suicide reasons to show if a player died with no reason
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)