spree not ending

Started by Cool, May 08, 2016, 11:51 AM

Previous topic - Next topic

Cool

spree not ending when i kill message cames spree ended but when i check spree its not ended :( :(
on playerkill functions
IncPlayerSpree(killer, 1);
   StartKillingSpree(killer);
   EndKillingSpree(player,killer);
   if (GetPlayerSpree(player) >= 1)
           DecPlayerSpree(player,GetPlayerSpree(player));
onplayerdeath functions
EndKillingSpree(player,255);
     if (GetPlayerSpree(player) >= 1)
        DecPlayerSpree(player,GetPlayerSpree(player));
spree end functions
function EndKillingSpree( p1, p2 )
{
if ( GetPlayerSpree( p1 ) >= 5 )
{
if ( p2 == 255 )
{
Message("[#32CD32][Spree][#FFFFFF]"+p1.Name+" Has Ended Their Own Killing Spree.");
EchoMessage("[#32CD32][Spree][#FFFFFF]"+p1.Name+" Has Ended Their Own Killing Spree.");
DecPlayerSpree(p1, GetPlayerSpree(p1));
}
else if ( p2 != 255 )
{
Message("[#32CD32][Spree][#FFFFFF]"+p2.Name+" Ended "+p1.Name+" Killing on Spree Of "+GetPlayerSpree(p1)+" Kills.");
EchoMessage(ICOL_RED+"** >> "+p2.Name+" TeamidToRGB(p1.Team)+""+p1.Name+" Killing on Spree Of "+GetPlayerSpree(p1)+" Kills".");
DecPlayerSpree(p1, GetPlayerSpree(p1));
}
}
}

KAKAN

try:
EndKillingSpree(killer,player);in your onplayerkill.

P.S:- That script looks shit, I mean the formatting
oh no

Cool

@KAKAN its working spree geting ending onplayer kill when when spree is start message cames spree started and spree ended while his spree in on but message cames ended

KAKAN

Show the other functions too and your spree command as well.
oh no

Cool

//===================================== Spree System ====================================================//
function GetPlayerSpree(player)
{
return  pstats[player.ID].KillingSpree;
}
function SetPlayerSpree(player)
{
 pstats[player.ID].KillingSpree = 0;
}
function IncPlayerSpree(player,amount)
{
 pstats[player.ID].KillingSpree = GetPlayerSpree(player) + amount;
}
function DecPlayerSpree(player,amount)
{
 pstats[player.ID].KillingSpree = GetPlayerSpree(player) - amount;
}
//==============================================================================
function StartKillingSpree( player )
{
if ( GetPlayerSpree( player ) >= 5 )
{
local kills = GetPlayerSpree(player);
local reward = GetPlayerSpree(player) * 500;
if ( kills == 5 )
{
Message("[#32CD32][Spree][#FFFFFF] "+player+" Is On a Killing Spree of "+kills+" Kills" );
EchoMessage(ICOL_LBLUE+ICOL_BOLD+"** >> "+player+" Is On a Killing Spree Of "+kills+" Kills" );
Announce( "~o~Killing-Spree!" , player,6);
IncCash( player, reward );
MessagePlayer("[#32CD32][Spree][#FFFFFF]Spree Reward:[ $"+reward+" ].",player);
}

else if ( kills == 10 )
{
Message("[#32CD32][Spree][#FFFFFF] "+player+" Is On a Killing Spree of "+kills+" Kills" );
EchoMessage(ICOL_LBLUE+ICOL_BOLD+"** >> "+player+" Is On Spree Of "+kills+" Kills" );
Announce( "~o~Killing-Spree!",player,6);
IncCash( player, reward );
MessagePlayer("[#32CD32][Spree][#FFFFFF]Spree Reward:[ $"+reward+" ].",player);
}

else if ( kills == 15 )
{
Message("[#32CD32][Spree][#FFFFFF] "+player+" Is On a Killing Spree of "+kills+" Kills" );
EchoMessage(ICOL_LBLUE+ICOL_BOLD+"** >> "+player+" Is On a Killing Spree Of "+kills+" Kills" );
Announce( "~o~Killing-Spree!",player,6);
IncCash( player, reward );
MessagePlayer("[#32CD32][Spree][#FFFFFF]Spree Reward:[ $"+reward+" ].",player);
}

else if ( kills == 20 )
{
Message("[#32CD32][Spree][#FFFFFF] "+player+" Is On a Killing Spree of "+kills+" Kills" );
EchoMessage(ICOL_LBLUE+ICOL_BOLD+"** >> "+player+" Is On a Killing Spree Of "+kills+" Kills" );
Announce( "~o~Killing-Spree!",player,6);
IncCash( player, reward );
MessagePlayer("[#32CD32][Spree][#FFFFFF]Spree Reward:[ $"+reward+" ].",player);
}

else if ( kills == 25 )
{
Message("[#32CD32][Spree][#FFFFFF] "+player+" Is On a Killing Spree of "+kills+" Kills" );
EchoMessage(ICOL_LBLUE+ICOL_BOLD+"** >> "+player+" Is On a Killing Spree Of "+kills+" Kills" );
Announce( "~o~Killing-Spree!",player,6);
IncCash( player, reward );
MessagePlayer("[#32CD32][Spree][#FFFFFF]Spree Reward:[ $"+reward+" ].",player);
}

else if ( ( kills >= 30 ) && ( kills % 5 == 0 ) )
{
Message("[#32CD32][Spree][#FFFFFF] "+player+" Is On a Killing Spree of "+kills+" Kills" );
EchoMessage(ICOL_LBLUE+ICOL_BOLD+"** >> "+player+" Is On Killing Spree Of "+kills+" Kills" );
Announce( "~o~Killing-Spree!",player,6);
IncCash( player, reward );
MessagePlayer("[#32CD32][Spree][#FFFFFF]Spree Reward:[ $"+reward+" ].",player);
}
}
}

else if ( cmd == "spree" )
    {
local b, plr;
    for( local i = 0; i <= GetMaxPlayers(); i++ )
{
plr = FindPlayer( i );
if ( ( plr ) && ( pstats[ player.ID ].Logged  ) && ( pstats[ plr.ID ].KillingSpree >= 5 ) )
{
    if ( b ) b = b + " - " + plr.Name + " (Spree: " + pstats[ plr.ID ].KillingSpree + ")";
else b = plr.Name + " (Spree: " + pstats[ plr.ID ].KillingSpree + " )";
}
    }

    if ( b ) Message("[#32CD32][Spree][#FFFFFF] Players on Spree:[ " + b + " ]" );
    else Message("[#32CD32][Spree][#FFFFFF] No Players with Spree" );
}

Mötley

#5
I could not see anything so I attempted to clean up the code unfortunately hear the code moved like crazy.
So you are going by what is in the class and increasing on every kill??????
If yes on a player death are you setting the score to equal 0?
also you dont need to locals

function StartKillingSpree( player )
{
    if ( GetPlayerSpree( player ) >= 5 ) {
      local
      kills = GetPlayerSpree(player),
          reward = GetPlayerSpree(player) * 500;
  return true;
    }

if ( kills == 5 ) {
      Message("[#32CD32][Spree][#FFFFFF] "+player+" Is On a Killing Spree of "+kills+" Kills" );
      EchoMessage(ICOL_LBLUE+ICOL_BOLD+"** >> "+player+" Is On a Killing Spree Of "+kills+" Kills" );
      Announce( "~o~Killing-Spree!" , player,6);
      IncCash( player, reward );
      MessagePlayer("[#32CD32][Spree][#FFFFFF]Spree Reward:[ $"+reward+" ].",player);
  return true;
}
   
if ( kills == 10 ) {
      Message("[#32CD32][Spree][#FFFFFF] "+player+" Is On a Killing Spree of "+kills+" Kills" );
      EchoMessage(ICOL_LBLUE+ICOL_BOLD+"** >> "+player+" Is On Spree Of "+kills+" Kills" );
      Announce( "~o~Killing-Spree!",player,6);
      IncCash( player, reward );
      MessagePlayer("[#32CD32][Spree][#FFFFFF]Spree Reward:[ $"+reward+" ].",player);
  return true;
    }

    if ( kills == 15 ) {
      Message("[#32CD32][Spree][#FFFFFF] "+player+" Is On a Killing Spree of "+kills+" Kills" );
      EchoMessage(ICOL_LBLUE+ICOL_BOLD+"** >> "+player+" Is On a Killing Spree Of "+kills+" Kills" );
      Announce( "~o~Killing-Spree!",player,6);
      IncCash( player, reward );
      MessagePlayer("[#32CD32][Spree][#FFFFFF]Spree Reward:[ $"+reward+" ].",player);
      return true;
}

    if ( kills == 20 ) {
      Message("[#32CD32][Spree][#FFFFFF] "+player+" Is On a Killing Spree of "+kills+" Kills" );
      EchoMessage(ICOL_LBLUE+ICOL_BOLD+"** >> "+player+" Is On a Killing Spree Of "+kills+" Kills" );
      Announce( "~o~Killing-Spree!",player,6);
      IncCash( player, reward );
      MessagePlayer("[#32CD32][Spree][#FFFFFF]Spree Reward:[ $"+reward+" ].",player);
      return true;
   }

   if ( kills == 25 ) {
     Message("[#32CD32][Spree][#FFFFFF] "+player+" Is On a Killing Spree of "+kills+" Kills" );
     EchoMessage(ICOL_LBLUE+ICOL_BOLD+"** >> "+player+" Is On a Killing Spree Of "+kills+" Kills" );
     Announce( "~o~Killing-Spree!",player,6);
     IncCash( player, reward );
     MessagePlayer("[#32CD32][Spree][#FFFFFF]Spree Reward:[ $"+reward+" ].",player);
return true;
   }

   if ( ( kills >= 30 ) && ( kills % 5 == 0 ) ) {
     Message("[#32CD32][Spree][#FFFFFF] "+player+" Is On a Killing Spree of "+kills+" Kills" );
     EchoMessage(ICOL_LBLUE+ICOL_BOLD+"** >> "+player+" Is On Killing Spree Of "+kills+" Kills" );
     Announce( "~o~Killing-Spree!",player,6);
     IncCash( player, reward );
     MessagePlayer("[#32CD32][Spree][#FFFFFF]Spree Reward:[ $"+reward+" ].",player);
     return true;
   }
}

KAKAN

#6
fack that shit. It can be done in a more easy way :D
oh no