i need help in OnPlayerDeath
#1

Guyz i need help when i use /kill cmd it shows the wrong message from OnPlayerDeath

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new Message[128];
    if(killerid == playerid) {
        format(Message,128,"{FFAF00}%s {B8FF02}has {F81414}died",PlayerName(playerid),reason);
    }else {
        format(Message,128,"{FFAF00}%s {B8FF02}has {F81414}killed {FFAF00}%s",PlayerName(killerid),PlayerName(playerid));
    }
    SendClientMessageToAll(COLOR_RED,Message);
    return 1;
}
any help please
Reply
#2

Not like this:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new Message[128];
    if(killerid == playerid) {
        format(Message,128,"{FFAF00}%s {B8FF02}has {F81414}died",PlayerName(playerid),reason);
    }else {
        format(Message,128,"{FFAF00}%s {B8FF02}has {F81414}killed {FFAF00}%s",PlayerName(killerid),PlayerName(playerid));
    }
    SendClientMessageToAll(COLOR_RED,Message); // this is wrong because we have 2 cases and just 1 function
    return 1;
}
Try this:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new Message[128];
    if(killerid == playerid) {
        format(Message,128,"{FFAF00}%s {B8FF02}has {F81414}died",PlayerName(playerid),reason);
        SendClientMessageToAll(COLOR_RED,Message); // so because we had 2 cases we maked 2 SendClientMessageToAll, one here...
    }else {
        format(Message,128,"{FFAF00}%s {B8FF02}has {F81414}killed {FFAF00}%s",PlayerName(killerid),PlayerName(playerid));
        SendClientMessageToAll(COLOR_RED,Message); // and 1 here, now we have 2 cases and 2 functions, do you understand me?
    }
    return 1;
}
That should do it!
Reply
#3

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new Message[128];
    new Lname[MAX_PLAYER_NAME], Kname[MAX_PLAYERS];
    GetPlayerName(playerid, Lname, sizeof(Lname));
    GetPlayerName(killerid, Kname, sizeof(Kname));
    if(killerid == playerid)
    {
        format(Message,sizeof(Message),"{FFAF00}%s {B8FF02}has {F81414}died %s",Lname, reason);
        SendClientMessageToAll(0xFF0000FF,Message);
    }
   else
   {
        format(Message,sizeof(Message),"{FFAF00}%s {B8FF02}has {F81414}killed {FFAF00}%s", Kname, Lname);
        SendClientMessageToAll(0xFF0000FF,Message);
    }
    return 1;
}
Reply
#4

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new Message[128];

    if(killerid == INVALID_PLAYER_ID)
    {
        format(Message, 128, "{FFAF00}%s {B8FF02}has {F81414}died", PlayerName(playerid), reason);
    }
    else
    {
        format(Message, 128, "{FFAF00}%s {B8FF02}has {F81414}killed {FFAF00}%s", PlayerName(killerid), PlayerName(playerid));
    }

    SendClientMessageToAll(COLOR_RED, Message);
    return 1;
}
When a player suicides, it doesn't show that they killed themselves. It shows that nobody (INVALID_PLAYER_ID) killed them.
Reply
#5

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new Message[128];

   [B] if(killerid == INVALID_PLAYER_ID)[/B]
    {
        format(Message, 128, "{FFAF00}%s {B8FF02}has {F81414}died", PlayerName(playerid), reason);
    }
    else
    {
        format(Message, 128, "{FFAF00}%s {B8FF02}has {F81414}killed {FFAF00}%s", PlayerName(killerid), PlayerName(playerid));
    }

    SendClientMessageToAll(COLOR_RED, Message);
    return 1;
}
When a player suicides, it doesn't show that they killed themselves. It shows that nobody (INVALID_PLAYER_ID) killed them.
That's because of killerid should equal player id
Код:
 if(killerid == playerid)
As shown in the posts above.
Reply
#6

Can i use like this??

pawn Код:
if(killerid == INVALID_PLAYER_ID)
Reply
#7

It actually should be:

PHP код:
if(killerid != INVALID_PLAYER_ID)//This means that if killerid doesn't equal to an invalid player ID.
{
     
//Rest of the code here.

If you see what Viper did you will understand why he chose "if(killerid == INVALID_PLAYER_ID)".
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)