if kills > 15 bla bla
#1

Hi all,i need to detect if player has more 15 kills.
Like:

if kills > 15

free armour/health bla bla.

Thanks.
Reply
#2

pawn Код:
new kill[MAX_PLAYERS]; // top
public OnPlayerDeath(playerid, reason)
{
    kill[killerid]++;
}
public OnPlayerStateChange(playerid, oldstate, newstate)
{
    if(kill[playerid] > 15)
    {
         // ... functions here
    }
    return 1;
}
Reply
#3

Thanks,i've a question.

I use custom made registration system and OnPlayerDeath i've this:

pawn Код:
SetPlayerScore(killerid,(GetPlayerScore(killerid))+1);
(This will add +1 at every kill of the player).

If i add your code,this will affect the code above or not?
Reply
#4

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
Thanks,i've a question.

I use custom made registration system and OnPlayerDeath i've this:

pawn Код:
SetPlayerScore(killerid,(GetPlayerScore(killerid))+1);
(This will add +1 at every kill of the player).

If i add your code,this will affect the code above or not?
Just put out from the keys: "{" "}"

Or above the code. If underneath, out from these keys:

pawn Код:
SetPlayerScore(killerid,(GetPlayerScore(killerid))+1);
Reply
#5

Ok,i've tried to paste the code where u say (adding fre armour),but it dont work.
Reply
#6

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
Ok,i've tried to paste the code where u say (adding fre armour),but it dont work.
Since you haven't over 15 kills, you can't receive this armour. If didn't work on StateChange (for me ever works things of this kind), then put a SetTimerEx, Forwarding before
Reply
#7

lol i lowered the kills to 3 just to test.

BTW i've fixed.
Reply
#8

No need for timer, or OnPlayerUpdate etc. Easiest solutions are usually the best.

Have fun.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    // I would also add this, so the score is spree, not the total kills:
    // SetPlayerScore(playerid, 0)
    if( killerid != INVALID_PLAYER_ID )
    {
        SetPlayerScore(killerid,(GetPlayerScore(killerid))+1);
        if( GetPlayerScore(killerid) == 15 )
        //OR the following, to give armor to player for each kill, when 15 kills are reached
        // if( GetPlayerScore(killerid) >= 15 )
        {
            SetPlayerArmour(killerid,GetPlayerArmour(killerid) + 10);
            // OR!
            SetPlayerArmour(killerid, 100);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)