SA-MP Forums Archive
Help with > OnPlayerDeath - 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: Help with > OnPlayerDeath (/showthread.php?tid=427250)



Help with > OnPlayerDeath - RiChArD_A - 01.04.2013

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.


Re: Help with > OnPlayerDeath - Pawnie - 01.04.2013

What do you want of it to do?

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


Re: Help with > OnPlayerDeath - Pawnie - 01.04.2013

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


AW: Help with > OnPlayerDeath - [AK]Nazgul - 01.04.2013

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



Respuesta: Help with > OnPlayerDeath - RiChArD_A - 01.04.2013

Thank you guys!