KillStreak Problem
#1

OnPlayerDeath
pawn Код:
Killstreak[killerid] ++ ;
    Killstreak[playerid] = 0 ;
    if(Killstreak[killerid] >= 2)
    {
        format(string,sizeof(string),"* Your Killstreak is %s", Killstreak[killerid]);
        SendClientMessage(killerid,LIGHTGREEN,string);
        return 1;
    }
    if(Killstreak[killerid] >= 5)
    {
        GivePlayerMoney(killerid,1000);
        SendClientMessage(killerid,LIGHTGREEN,"Here's an Extra $1000!");
        return 1;
    }
    if(Killstreak[killerid] == 6)
    {
        GivePlayerWeapon(playerid,24,100);
        SendClientMessage(killerid,LIGHTGREEN,"Here's a Extra Desert Eagle Ammo!");
        return 1;
    }
It's not sending the messages for some reason, nor giving the desert eagle
Reply
#2

Because every time the OnPlayerDeath been called, it's reseting the variable.
pawn Код:
Killstreak[playerid] = 0 ;
Reply
#3

I mean, if I kill 5 people without dying, I get no messages or the extra cash messages.
Reply
#4

Quote:
Originally Posted by Dwane
Посмотреть сообщение
Because every time the OnPlayerDeath been called, it's reseting the variable.
pawn Код:
Killstreak[playerid] = 0 ;
for "playerid", also known as the player who is dieing.
It is being set "++" to the killerid.
Reply
#5

oh! Excuse me, I missread the playerid. I saw the reseting only.
pawn Код:
Killstreak[ killerid ] ++;
Killstreak[ playerid ] = 0;
switch( Killstreak[ killerid ] )
{
    case 2:
    {
        format(string,sizeof(string),"* Your Killstreak is %s", Killstreak[killerid]);
        SendClientMessage(killerid,LIGHTGREEN,string);
        return 1;
    }
    case 5:
    {
        GivePlayerMoney(killerid,1000);
        SendClientMessage(killerid,LIGHTGREEN,"Here's an Extra $1000!");
        return 1;
    }
    case 6:
    {
        GivePlayerWeapon(playerid,24,100);
        SendClientMessage(killerid,LIGHTGREEN,"Here's a Extra Desert Eagle Ammo!");
        return 1;
    }
}
Reply
#6

The above wasn't working, but CookieJar, How do I set the killstreaks to the killer then?
Reply
#7

I'm using the code exactly like you, except that I have
pawn Код:
Killstreak[killerid] += 1;
and it's working.
Reply
#8

Update of code
pawn Код:
Killstreak[killerid] += 1;
    Killstreak[ playerid ] = 0;
/*  switch( Killstreak[ killerid ] )
    {
        case 2:
        {
            format(string,sizeof(string),"* Your Killstreak is %s", Killstreak[killerid]);
            SendClientMessage(killerid,LIGHTGREEN,string);
            return 1;
        }
        case 5:
        {
            GivePlayerMoney(killerid,1000);
            SendClientMessage(killerid,LIGHTGREEN,"Here's an Extra $1000!");
            return 1;
        }
        case 6:
        {
            GivePlayerWeapon(playerid,24,100);
            SendClientMessage(killerid,LIGHTGREEN,"Here's a Extra Desert Eagle Ammo!");
            return 1;
        }
    }*/

    if(Killstreak[killerid] >= 2)
    {
        format(string,sizeof(string),"* Your Killstreak is %s", Killstreak[killerid]);
        SendClientMessage(killerid,LIGHTGREEN,string);
        return 1;
    }
    if(Killstreak[killerid] >= 5)
    {
        GivePlayerMoney(killerid,1000);
        SendClientMessage(killerid,LIGHTGREEN,"Here's an Extra $1000!");
        return 1;
    }
    if(Killstreak[killerid] == 6)
    {
        GivePlayerWeapon(playerid,24,100);
        SendClientMessage(killerid,LIGHTGREEN,"Here's a Extra Desert Eagle Ammo!");
        return 1;
    }
i've tried both versions of what was posted and also what cookie posted, It's not sending the message out.
Reply
#9

Quote:
Originally Posted by CookieJar
Посмотреть сообщение
I'm using the code exactly like you, except that I have
pawn Код:
Killstreak[killerid] += 1;
and it's working.
++ and += 1 are the same thing

++ = incrementally increase the value of the variable

+= 1 = increase it by one - in other words increment it
Reply
#10

Quote:
Originally Posted by [ABK]Antonio
Посмотреть сообщение
++ and += 1 are the same thing

++ = incrementally increase the value of the variable

+= 1 = increase it by one - in other words increment it
I do know that, but my code is exactly the same and works perfectly.

P.S: Didn't notice the if(Killstreak[playerid] >= 2)
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)