Assigning kills to players
#1

Hello,
I have this thing where the army can blow up the criminals with a missile...
How can i assign the kills to the player?

Thanks,
stormchaser206
Reply
#2

OnPlayerDeath?

I don't know actually, but under OnPlayerDeath, make a script with (killerid)?
Reply
#3

I know under OnPlayerDeath, but the code?
Reply
#4

Use,
pawn Код:
if(reason == 51)
{
 /// your code
}
OnPlayerDeath.
https://sampwiki.blast.hk/wiki/Weapons
Reply
#5

Quote:
Originally Posted by Kitten
Посмотреть сообщение
Use,
pawn Код:
if(reason == 51)
{
 /// your code
}
OnPlayerDeath.
https://sampwiki.blast.hk/wiki/Weapons
I don't get it kind of.
Reply
#6

Which type of missile is it?
RPG or HS Rocket?
Reply
#7

It really doesn't matter... they're both the same.
If you're trying to find out HOW to kill them, try using: CreateExplosion(X, Y, Z, Radius);

Or you could use SetPlayerHealth and set to 0 etc.
Reply
#8

Seeing as there is no way to actually relate the killer and the victim using native functions (For explosions at least) you would need to do the following:

Create a variable that would change depending on who send the missle, for example, if it is some kind of turret, you would need to find out who is firing the turret by declaring and using:

Firedturret = playerid;

Then you need to find out which player died using the reason code that Kitten gave you and in this you would find out which playerid used the turret and manually assign the kill to the players statistics.

This is a way of doing it with no code, if you need any more help just post what code you have that's relevant and I'll give you a hand.
Reply
#9

Would this work?:
pawn Код:
if(NearStrike[playerid] == 1)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(UsedStrike[i] == 1)
            {
                UsedStrike[i] = 0;
                SendDeathMessage(i, playerid, 51);
                format(string, sizeof(string),"-| %s(%d) has been killed by %s(%d)'s missile strike |-", name, playerid, name2, i);
                SendClientMessageToAll(COLOR_BLUE, string);
                GivePlayerMoney(i, 2500);
                SetPlayerScore(i, GetPlayerScore(i) + 2);
                PlayerInfo[i][Kills]++;
            }
        }
    }
Reply
#10

Declare "UsedStrike" as "UsedStrike" rather than "UsedStrike[MAX_PLAYERS]"

pawn Код:
if(NearStrike[playerid] == 1)
    {                  
                SendDeathMessage(UsedStrike, playerid, 51);
                format(string, sizeof(string),"-| %s(%d) has been killed by %s(%d)'s missile strike |-", name, playerid, name2, UsedStrike);
                SendClientMessageToAll(COLOR_BLUE, string);
                GivePlayerMoney(UsedStrike, 2500);
                SetPlayerScore(UsedStrike, GetPlayerScore(UsedStrike) + 2);
                PlayerInfo[UsedStrike][Kills]++;
                UsedStrike = 0;
    }
When you are assigning the "UsedStrike" variable, assign "playerid" rather than "1" it just saves making a for loop..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)