Raised This Month: $ Target: $400
 0% 

Isn't the killer/victim same


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 09-23-2011 , 18:07   Isn't the killer/victim same
Reply With Quote #1

How to check isn't the victim same for 2nd or even 3rd time ?

Like If I've killed Player5 3times a row, I want message to be displayed, You have killed Player5 3 times in a row
reinert is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 09-23-2011 , 18:18   Re: Isn't the killer/victim same
Reply With Quote #2

PHP Code:
new Kills[33][33];
new 
MaxPlayers;

public 
plugin_init()
{
    
register_event("DeathMsg""OnDeathMsg""a""1>0");

    
MaxPlayers get_maxplayers();
}

public 
client_disconnect(client)
{
    
arrayset(Kills[client], 0sizeof Kills[]);

    for (new 
1<= MaxPlayersi++)
        
Kills[i][client] = 0;
}

public 
OnDeathMsg()
{
    new 
killer read_data(1);
    new 
victim read_data(2);

    if (
killer == victim)
        return;

    if (++
Kills[killer][victim] == 3)
    {
        
// killer killed victim 3 times in a row
    
}

    
Kills[victim][killer] = 0;

__________________
hleV is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 09-23-2011 , 18:19   Re: Isn't the killer/victim same
Reply With Quote #3

Killing the same player without killing anyone else in between or killing a player more than once without you beeing killed by him ?

Example with the 2nd, like the when you dominate someone in TF2:
Code:
new g_iKilled[33][33]
new g_iMaxPlayers

public plugin_init()
{
    register_event("DeathMsg", "player_killed", "a")

    g_iMaxPlayers = get_maxplayers()
}

public player_killed()
{
    new victim = read_data(2)
    new killer = read_data(1)

    if(id != killer && 1 <= killer <= g_iMaxPlayers)
    {
        g_iKilled[victim][killer] = 0

        if(++g_iKilled[killer][victim] == 3)
        {
            new szKiller[32]
            new szVictim[32]

            get_user_name(killer, szKiller, charsmax(szKiller))
            get_user_name(victim, szVictim, charsmax(szVictim))

            client_print(0, print_chat, "**** %s is dominating %s ****", szKiller, szVictim)
        }
    }
}

public client_putinserver(id)
{
    for(new i = 1; i <= g_iMaxPlayers; i++)
    {
        g_iKilled[id][i] = 0
        g_iKilled[i][id] = 0
    }
}
untested :}


EDIT: pff, I forgot this forum doesn't notify me if someone posted while I was writing xD
__________________
Hunter-Digital is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-23-2011 , 18:19   Re: Isn't the killer/victim same
Reply With Quote #4

Make 2d array and count each time one id killed another

Say id 3 kills id 9

new iKills[ 33 ][ 33 ];
iKills[ 9 ][ 3 ]++;

Edit: lols @ 3 posts at the same time
__________________
Bugsy is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 09-23-2011 , 18:25   Re: Isn't the killer/victim same
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
Make 2d array and count each time one id killed another

Say id 3 kills id 9

new iKills[ 33 ][ 33 ];
iKills[ 9 ][ 3 ]++;

Edit: lols @ 3 posts at the same time
Just as hleV did, didn't he the same u just said ?
reinert is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 09-23-2011 , 18:27   Re: Isn't the killer/victim same
Reply With Quote #6

Yes we all suggested the same method, so you have your answer

But I'm still curious about:
Quote:
Originally Posted by Hunter-Digital View Post
Killing the same player without killing anyone else in between or killing a player more than once without you beeing killed by him ?
__________________
Hunter-Digital is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 09-23-2011 , 18:29   Re: Isn't the killer/victim same
Reply With Quote #7

Killing the same player without killing someone else in between ;p

also if I'm returning in this:

PHP Code:
if(++Kills[attacker][victim] >= 3)
                return 
PLUGIN_HANDLED
Is it good to have this: Kills[victim][attacker] = 0; after it ?

like:
PHP Code:
if(++Kills[attacker][victim] >= 3)
                return 
PLUGIN_HANDLED;
            
            
Kills[victim][attacker] = 0

Last edited by reinert; 09-23-2011 at 18:33.
reinert is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-23-2011 , 18:33   Re: Isn't the killer/victim same
Reply With Quote #8

Edit: Eliminated g_iLastKilled[ 33 ] array, now using first cell of g_iKills[ iKiller ][] (since it does not get used anyway) to store the last person iKiller killed.

PHP Code:
#define LastKilled 0
new g_iKills33 ][ 33 ];

public 
KilliVictim iKiller )
{
    if ( 
g_iKillsiKiller ][ LastKilled ] == iVictim )
    {
        if ( ++
g_iKillsiKiller ][ iVictim ] == )
        {
            
//third time killing this person, no kills inbetween
        
}
    }
    else
    {
        
g_iKillsiKiller ][ g_iKillsiKiller ][ LastKilled ] ] = 0;

        
g_iKillsiKiller ][ iVictim ] = 1;
        
g_iKillsiKiller ][ LastKilled ] = iVictim;
    }

__________________

Last edited by Bugsy; 09-23-2011 at 21:16.
Bugsy is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 09-23-2011 , 18:37   Re: Isn't the killer/victim same
Reply With Quote #9

In that case, you need adjustments to the codes provided by me or hlev:

Code:
new g_iTarget[33]
new g_iKilled[33]

//....

public player_killed()
{
   //... get victim, killer, check if player, etc

   if(g_iTarget[victim] == killer) // reset victim's kills against killer
   {
       g_iTarget[victim] = 0
       g_iKilled[victim] = 0
   }

   if(g_iTarget[killer] != victim) // reset count because he killed someone else
   {
       g_iTarget[killer] = victim
       g_iKilled[killer] = 1
   }
   else if(++g_iKilled[killer] == 3)
   {
       // killed the same player 3 times without killing anyone else in between or beeing killed by him
   }
}
EDIT: seriously too much traffic on this thread =)



Quote:
Originally Posted by reinert View Post
also if I'm returning in this:

PHP Code:
if(++Kills[attacker][victim] >= 3)
                return 
PLUGIN_HANDLED
Is it good to have this: Kills[victim][attacker] = 0; after it ?

like:
PHP Code:
if(++Kills[attacker][victim] >= 3)
                return 
PLUGIN_HANDLED;
            
            
Kills[victim][attacker] = 0
Well, think about it... the kills on the victim against attacker will be reset when the attacker kills the victim the first 2 times.
__________________

Last edited by Hunter-Digital; 09-23-2011 at 18:41.
Hunter-Digital is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 09-23-2011 , 18:41   Re: Isn't the killer/victim same
Reply With Quote #10

Isn't the bugsy's code good ? It looks more simply
reinert is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:32.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode