how to detect if player killed himself
#1

PHP код:
if ( killerid != INVALID_PLAYER_ID )
{
   
// everything works fine here when player kills other player
}
else
{
    
// when player kills himself this part should be executed but it is not
    // tried with jumping ,bombs..

Reply
#2

You could try:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid == playerid || killerid == INVALID_PLAYER_ID)
    {
        //Insert your code here
    }
    else
    {
        //Insert your code here
    }
    return 1;
}
Reply
#3

Thanks ,but still not working.
Reply
#4

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(IsPlayerConnected(killerid))
    {
        //Code for killerid goes here
    }
    //Code for playerid goes here
    return 1;
}
Reply
#5

Are you kidding me ?
Reply
#6

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid == playerid)
    {
        //He killed himself
    }
    else
    {
        //Insert your code here
    }
    return 1;
}
Reply
#7

Already tried that.
Somehow doesn't work.
Reply
#8

Quote:
Originally Posted by [MWR]Blood
Посмотреть сообщение
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(IsPlayerConnected(playerid))
    {
        //Code for killerid goes here
    }
    //Code for playerid goes here
    return 1;
}
Blood, I think it should be if(IsPlayerConnected(killerid)), instead of playerid. But that isn't really important.
______________________________
Now on topic, OnPlayerDeath has another parameter, reason, I'm pretty sure you noticed it. You can see the reasons here.
Also take a look to SendDeathMessage and OnPlayerDeath.

In the wiki says: "if killerid was INVALID_PLAYER_ID the player killed themselves (i.e. falling)"

Probably, this isn't the answer which you want, but give a try.
Reply
#9

Well it is kind of important. You can't detect a player dying if that player isn't even connected... it would be a dead or useless function. You could always try switching to the reason of death.
Example:
pawn Код:
switch(reason)
{
    case 49 .. 54:
    {
        //Insert suicide code here
    }
}
Reply
#10

Quote:
Originally Posted by irinel1996
Посмотреть сообщение
Blood, I think it should be if(IsPlayerConnected(killerid)), instead of playerid. But that isn't really important.
______________________________
Now on topic, OnPlayerDeath has another parameter, reason, I'm pretty sure you noticed it. You can see the reasons here.
Also take a look to SendDeathMessage and OnPlayerDeath.

In the wiki says: "if killerid was INVALID_PLAYER_ID the player killed themselves (i.e. falling)"

Probably, this isn't the answer which you want, but give a try.
Yeah, soz. FML >_>
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)