SA-MP Forums Archive
how to detect if player killed himself - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: how to detect if player killed himself (/showthread.php?tid=371101)



how to detect if player killed himself - detter - 22.08.2012

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..




Re: how to detect if player killed himself - clarencecuzz - 22.08.2012

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;
}



Re: how to detect if player killed himself - detter - 22.08.2012

Thanks ,but still not working.


Re: how to detect if player killed himself - [MWR]Blood - 22.08.2012

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



Re: how to detect if player killed himself - detter - 22.08.2012

Are you kidding me ?


Re: how to detect if player killed himself - RedJohn - 22.08.2012

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



Re: how to detect if player killed himself - detter - 22.08.2012

Already tried that.
Somehow doesn't work.


Re: how to detect if player killed himself - [DOG]irinel1996 - 22.08.2012

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.


Re: how to detect if player killed himself - clarencecuzz - 22.08.2012

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
    }
}



Re: how to detect if player killed himself - [MWR]Blood - 22.08.2012

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 >_>