Spree error :(

Started by KAKAN, Jul 26, 2015, 05:26 AM

Previous topic - Next topic

KAKAN

Here is my spree system which doesn't throw out any errors, but it doesn't work also :(
[spoiler="Functions"]//===================================== Spree System ====================================================//
function GetPlayerSpree(player)
{
   return stats[player.ID].KillingSpree;
}
function SetPlayerSpree(player)
{
   stats[player.ID].KillingSpree = 0;
}
function IncPlayerSpree(player,amount)
{
   stats[player.ID].KillingSpree = GetPlayerSpree(player) + amount;
}
function DecPlayerSpree(player,amount)
{
   stats[player.ID].KillingSpree = GetPlayerSpree(player) - amount;
}
//==============================================================================
function StartKillingSpree( player )
{
   if ( GetPlayerSpree( player ) >= 5 )
    {
   local kills = GetPlayerSpree(player);
           if ( kills == 5 ) Message( player + " is on a Killing Spree with " + kills + " kills in a row!" );
           else if ( kills == 10 ) Message( player + " is Dangerous!  Killing Spree with " + kills + " kills in a row!" );
           else if ( kills == 15 ) Message( player + " is Murderous!!  Deadly Killing Spree with " + kills + " kills in a row!" );
           else if ( kills == 20 ) Message( player + " is Psychotic!!!  Insane Killing Spree with " + kills + " kills in a row!" );
           else if ( kills == 25 ) Message( player + " is an Assassin!!!!  Professional Killing Spree with " + kills + " kills in a row!" );
         else if ( ( kills >= 30 ) && ( kills % 5 == 0 ) ) Message( player + " is UNSTOPPABLE!!!!  Untouchable Killing Spree with " + kills + " kills in a row!" );
     }
}
//==============================================================================
function EndKillingSpree( p1, p2 )
{
   if ( GetPlayerSpree( p1 ) >= 5 )
    {
       if ( p2 == 255 )
        {
                Message(" " + p1.Name + " has ended their own killing spree.");
                DecPlayerSpree(p1, GetPlayerSpree(p1));
        }
      else if ( p2 != 255 )
        {
               Message( p2.Name + " ended " + p1.Name + "'s Killing Spree of " + GetPlayerSpree(p1) + " kills in a row.");
               DecPlayerSpree(p1, GetPlayerSpree(p1));
      }
    }
}[/spoiler]

[spoiler="Death and kill"]function onPlayerDeath( player, reason )
{
   EndKillingSpree(player,255);
        if (GetPlayerSpree(player) >= 1) DecPlayerSpree(player,GetPlayerSpree(player));
}

function onPlayerKill( player, killer, reason, bodypart )
{
IncPlayerSpree(player, 1);
      StartKillingSpree( player );
      EndKillingSpree(killer,player);
      if (GetPlayerSpree(player) >= 1) DecPlayerSpree(player,GetPlayerSpree(player));
}
[/spoiler]

[spoiler="Commands"]   else if ( cmd == "spree" )
    {
      local b, plr;
       for( local i = 0; i <= GetMaxPlayers(); i++ )
      {
      plr = FindPlayer( i );
      if ( ( plr ) && ( stats[ plr.ID ].Logged ) && ( stats[ plr.ID ].KillingSpree >= 5 ) )
      {
       if ( b ) b = b + " - " + plr.Name + " (Spree: " + stats[ plr.ID ].KillingSpree + ")";
      else b = plr.Name + " (Spree: " + stats[ plr.ID ].KillingSpree + " )";
      }
       }
         
       if ( b ) Message( "** Players on Spree:[ " + b + " ]" );
       else Message( "** No Players with Spree" );
   }[/spoiler]

These were working fine yesterday, but not today
oh no

.

Well, I don't see any type of error specified. So they must be working :-\
.

KAKAN

I said nah, these didn't throw out any error, these were working fine yesterday, but the problem was (ex)
My name(who made the spree):- KAKAN
Other Name(who was killed atlast before the spree):- Test
Then it would show:-
Test is on a killing spree of ... row...
It should show:-
KAKAN is on a killimg spree of...........
oh no

MacTavish

Change

function onPlayerKill( player, killer, reason, bodypart )

To

function onPlayerKill(killer,player, reason, bodypart )

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

.

Well, I keep seeing you bragging with your coding "skillz" all over the forum. And since you know how this code is supposed to work. And there isn't some weird a$$ error you can't understand. Then I suppose you could use those mad "skillz" to find the mistake (coz this isn't an error).

Unless... You just copy shit from other people and and you have no programming knowledge at all. Therefore, fixing snippet would do you no good because you'll simply come up with the next one.
.

MacTavish

@S.L.C are you talking about me? :-\

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

.

Quote from: Beztone on Jul 26, 2015, 05:47 AM@S.L.C are you talking about me? :-\

What? No :-\ What gave you that idea?
.

KAKAN

Quote from: Beztone on Jul 26, 2015, 05:40 AMChange

function onPlayerKill( player, killer, reason, bodypart )

To

function onPlayerKill(killer,player, reason, bodypart )
Still then not wrking
oh no

Kratos_


Quote from: KAKAN on Jul 26, 2015, 05:54 AMStill then not wrking

Magnifying callback onPlayerKill :-

-> You're creating victim's spree by passing his instance.
// Increasing victim's spree by 1
IncPlayerSpree(player, 1);


-> You're attempting to announce the victim's spree if spree is 5 or divisible by 5 .
// Starting victim's spree
StartKillingSpree( player );


-> You're attempting to end killer's spree (  who eventually wasn't on any spree ) due to what you did on above steps .
// Ending killer's spree & victim is the man on spree currently
EndKillingSpree(killer,player);


-> Victim's spree reverted back to zero .
// Reverting back victim's spree to 0
if (GetPlayerSpree(player) >= 1) DecPlayerSpree(player,GetPlayerSpree(player));




Conclusion : No one is on spree .

Quote from: KAKAN on Jul 26, 2015, 05:37 AMI said nah, these didn't throw out any error

How're you assuming to get "error messages" ? This isn't syntax error . This is logical error .

You wont get any spree announcement . Because , your StartKillingSpree function checks whether spree status is 5 or its multiple ? While you're reverting it back to 0 in the 4th step I mentioned above . You wont get spree end announcement as well cuz killer wasn't on spree anytime & you're attempting to end his spree .
All this will behave like a blank system . ( On console as well as the ingame ) .

Off-Topic : Why're you creating overheads for all this ? For example your  IncPlayerSpree function could be removed & something like this could be written .

++stats[killer.ID].KillingSpree;
Indeed this whole system need not any overheads except the one Spree function to stop cluttering the playerkill callback .
In the middle of chaos , lies opportunity.

KAKAN

Oh! Ty, I'll try it, when I'll get my desktop, anyways I'll keep this "logical error" in my mind
oh no