Help with > OnPlayerDeath
#1

Hi, I have this on sv but it resets the full money of the player who gets killed.
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
SetPlayerChatBubble(playerid, "XC", 0xFFFF0000, 100.0, 3000);
new playercash;
    if(killerid == INVALID_PLAYER_ID) {
        ResetPlayerMoney(playerid);
    } else {
            SendDeathMessage(killerid,playerid,reason);
            SetPlayerScore(killerid,GetPlayerScore(killerid)+2);
            playercash = GetPlayerMoney(playerid);
            if (playercash > 0)  {
                GivePlayerMoney(killerid, playercash);
                ResetPlayerMoney(playerid);
            }
            else
            {
            }
        }
    return 1;
}
What I want is to give the killer +2 score and $100 and to the victim -1 score and $-100. Can anyone help me with this . Thank you.
Reply
#2

What do you want of it to do?

edit: nvm didnt read the entire thing, give me 2 secs
Reply
#3

Here you go
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(killerid,playerid,reason); //Sending the death msg
    SetPlayerChatBubble(playerid, "XC", 0xFFFF0000, 100.0, 3000);
	if(killerid != INVALID_PLAYER_ID) // Valid killer, give cash+score
 	{
		SetPlayerScore(killerid, GetPlayerScore(killerid) + 2); //Giving +2 score to the killer
		GivePlayerMoney(killerid, 100); //Giving 100$ to the killer
		
                GivePlayerMoney(playerid, -100); //taking 100$ from the player that died
                SetPlayerScore(playerid, GetPlayerScore(playerid) - 1);
	}
	return 1;
}
Edit: fixed the code
Reply
#4

You lose $100 everytime you die anyway, so if you don't want the killed player to lose $200, scratch the
Код:
GivePlayerMoney(playerid,-100);
Reply
#5

Thank you guys!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)