Nuke for 30 kill streak
#1

I wanted to make something for players with 30 kill streak. Well, I thought it was going to work, so I tried it but nothing happened when I typed /nuke. Then I removed the 30 kill part and suddenly it worked. How can I make it for 30 kills in a row only, I know how to but not without bugs...
Here is my code:

pawn Код:
public Nuke()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            new Float:X,Float:Y,Float:Z;
            GetPlayerPos(i,X,Y,Z);
            CreateExplosion(X,Y,Z,6,1000000);
            CreateExplosion(X,Y,Z,6,1000000);
            SetTimer("Nend",5000,0);
            SendClientMessageToAll(COLOR_RED,"The nuclear bomb has been exploded!");
            return 1;
        }
        return 1;
    }
    return 1;
}
pawn Код:
if (PlayerKills[killerid] == 30)
    {
        SendClientMessage(killerid,COLOR_RED,"You have access to /nuke!");
        SendClientMessage(killerid,COLOR_RED,"WARNING: Activating nuke will destroy the whole city!");
        format(string, sizeof(string), "%s is on a Killing Spree! [30 kills]", kName);
        SendClientMessageToAll(COLOR_UFAC, string);
        return 1;
    }
            }
        }
    }
    return 1;
}
pawn Код:
dcmd_nuke(playerid,params[])
{

        #pragma unused params
        SetTimer("Nuke",10000,0);
        SendClientMessageToAll(COLOR_RED,"Nuclear Bomb has been activated!");
        SendClientMessageToAll(COLOR_RED,"The bomb goes off in 10 seconds!");
        NC[playerid] = 0;
        return 1;
}
Reply
#2

I think this will work

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
   PlayerKills[killerid]++;
   if (PlayerKills[killerid] == 30)
   {
      SendClientMessage(killerid,COLOR_RED,"You have access to /nuke!");
      SendClientMessage(killerid,COLOR_RED,"WARNING: Activating nuke will destroy the whole city!");
      format(string, sizeof(string), "%s is on a Killing Spree! [30 kills]", kName);
      SendClientMessageToAll(COLOR_UFAC, string);
      return 1;    
   }
   return 1;
}
pawn Код:
dcmd_nuke(playerid,params[])
{
   #pragma unused params
   if(PlayerKills[playerid] >= 30) // if kills is 30 or more
   {
      SetTimer("Nuke",10000,0);
      SendClientMessageToAll(COLOR_RED,"Nuclear Bomb has been activated!");
      SendClientMessageToAll(COLOR_RED,"The bomb goes off in 10 seconds!");
      NC[playerid] = 0;
   }
   return 1;
}
Reply
#3

@ the 2nd one, that's no kill streak I think, is it.
Reply
#4

That'll do, but you'll have to reset the variable (PlayerKills) to 0 when the player himself dies.
Reply
#5

pawn Код:
if(killerid == INVALID_PLAYER_ID) {
PlayerKills[playerid] = 0;
} else {
PlayerKills[killerid]++;
PlayerKills[playerid] = 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)