If player kills player [ REP + ]
#1

Hi guys,

i am here with another question.

I am doing DEATH/KILL system, i have already done, that if player kills another player, he will earn his money.

But i am not sure how to do, if player gets killed by another player, it will reset him his money. But just, if player gets killed by another player.

Couse the whole script is, that player who kill someone, gets his money, so basically the dead player, who got killed have lose his money, couse the deads player money, are going to the killerid.

So, yeah, that is the whole thing, thanks guys.
Reply
#2

im confused ..but;

making a player loose money is just GivePlayerMoney(playerid, - 100); // or - 50 depending how much you want it to loose
Reply
#3

Onplayerdeath:

pawn Код:
new pMoney = GetPlayerMoney( playerid ); // assigning the amount of cash the player that got killed has to a variable so we can use it later on :)
ResetPlayerMoney( playerid ); // not sure if this is what it's called, if it gives errors ****** it, using phone atm so yea..
GivePlayerMoney( killerid, pMoney ); // giving the killer the money of the one he killed.
Reply
#4

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
    {
       // Award $1000 to the killer
       GivePlayerMoney(killerid, 1000);
       SendClientMessage(killerid, -1, "You have been awarded $1000 for the kill.");
    }
 
    // Take $500 from the player who died.
    GivePlayerMoney(playerid, -500);
}
https://sampwiki.blast.hk/wiki/Function:GivePlayerMoney
Reply
#5

Well guys, i dont think so, you did understand, what do i want. You are sending me super basic scripts that i already know, ofc. they are not soultion of my problem.

My first "try" which is working well, and its first part of the system:

Код:
GivePlayerMoney(killerid, GetPlayerMoney(playerid));
	new string[55];
	format(string, sizeof(string), "You killed player %s, and earned his money $%d.", GetName(playerid), GetPlayerMoney(playerid));
	SendClientMessage(killerid, COLOR_DIED, string);
So this little script does, that if player kills someone, he will earn all his money.

The second part, which is unknown for me, that is why i am posting this help topic, is how to do, that player who got killed, will lose his all money.

If he die from falling down, or type /kill, he cant lose his money, so that is little confusing.

You guys told me to use:
GivePlayerMoney(playerid, -amount);

If you would use that, the player will loose all his money everytime, he will die. I need, to get his money reseted just IF HE GETS KILLED BY ANOTHER PLAYER, WHO CAN GET HIS MONEY FROM HIM.

Hope you understanded guys.
Reply
#6

Check if the killerid is valid.
pawn Код:
if(killerid != INVALID_PLAYER_ID) // Makes sure that the killerid is an actual player
{
    ResetPlayerMoney(playerid); // Sets money to 0
}
Reply
#7

Thank you, i never worked with that function before, now i will know.

REP +
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)