Raised This Month: $ Target: $400
 0% 

Kill 6 players in 15 seconds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 03-09-2013 , 07:30   Kill 6 players in 15 seconds
Reply With Quote #1

How to catch this?
Backstabnoob is offline
bboygrun
CHOMP
Join Date: May 2010
Location: France
Old 03-09-2013 , 07:57   Re: Kill 6 players in 15 seconds
Reply With Quote #2

It must be something like that :

PHP Code:
#include < amxmodx >
#include < hamsandwich >

#define MAX_PLAYERS    32

#define VERSION     "1.0.0"

new Floatg_fPlayerTimeMAX_PLAYERS ];
new 
g_iPlayerKillsMAX_PLAYERS ];

public 
plugin_init( ) 
{
    
register_plugin"Catch Kills"VERSION"Bboy" );
    
    
RegisterHamHam_Killed"player""CPlayer__Killed_P"true );
}

public 
client_disconnectiPlayer )
{
    
g_fPlayerTimeiPlayer ] = 0.0;
}

public 
CPlayer__Killed_P( const iVictim, const iAttacker )
{
    if( 
<= iAttacker <= MAX_PLAYERS )
    {
        new const 
FloatfCurrentTime get_gametime( );
        
        if( 
fCurrentTime g_fPlayerTimeiAttacker ] <= 15.0 )
        {
            if( ++ 
g_iPlayerKillsiAttacker ] == )
            {
                
CPlayer__KillsDoneiAttacker );
            }
        }
        else
        {
            
g_fPlayerTimeiAttacker ] = fCurrentTime;
            
g_iPlayerKillsiAttacker ] = 1;
        }
    }
}

CPlayer__KillsDone( const iPlayer )
{
    
// Code

__________________

Last edited by bboygrun; 03-09-2013 at 08:00. Reason: Forgot to check if iAttacker was player ._.
bboygrun is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 03-09-2013 , 07:59   Re: Kill 6 players in 15 seconds
Reply With Quote #3

Thanks, I'll try it soon.
Backstabnoob is offline
bboygrun
CHOMP
Join Date: May 2010
Location: France
Old 03-09-2013 , 08:01   Re: Kill 6 players in 15 seconds
Reply With Quote #4

I edited code, forgot to check if iAttacker was player ._.

Gonna be ok now.
__________________
bboygrun is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 03-09-2013 , 08:09   Re: Kill 6 players in 15 seconds
Reply With Quote #5

I didn't check the whole code, but in the player check, MAX_PLAYERS should be replaced with a value (cached) of get_maxplayers().
__________________
hleV is offline
bboygrun
CHOMP
Join Date: May 2010
Location: France
Old 03-09-2013 , 08:24   Re: Kill 6 players in 15 seconds
Reply With Quote #6

He has to change the define, that's all
__________________
bboygrun is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 03-09-2013 , 08:34   Re: Kill 6 players in 15 seconds
Reply With Quote #7

What if this happens:

Player killed someone, therefore the timer started.
After 10 seconds, the player kills other 4 players.
The timer has ended, while the player had only 5 kills.

A few seconds later, the player kills two more people.
Because the first timer has already ended, the 4 kills won't be counted.

Even though the 4 kills + 2 kills would be for example in 10 seconds, the plugin won't catch this event.

It's not that easy to describe the event, so I hope you understood what I just wrote. This is also mainly the reason I started the thread.

Last edited by Backstabnoob; 03-09-2013 at 08:35.
Backstabnoob is offline
bboygrun
CHOMP
Join Date: May 2010
Location: France
Old 03-09-2013 , 08:39   Re: Kill 6 players in 15 seconds
Reply With Quote #8

It's what you asked for.

Quote:
A few seconds later, the player kills two more people.
Because the first timer has already ended, the 4 kills won't be counted.
Then timer is set to 0.0 g_iPlayerKills = 2

If that's not what you are looking for, tell me exactly what you want :d.
__________________
bboygrun is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 03-09-2013 , 08:42   Re: Kill 6 players in 15 seconds
Reply With Quote #9

Your way basically "cycles" the timer.
When it ends, it starts a new one after the player kills someone.

When the player kills 3 people 5 seconds before the timer ends and kills other 3 people right after the timer ends, he would still kill 6 people under 15 seconds but your method wouldn't recognize it.

Edit: This would probably work, but I don't like the array shifting part. Any better ideas?

Code:
#include <amxmodx> #include <amxmisc> #include < hamsandwich > #define PLUGIN "New Plugin" #define VERSION "1.0" #define AUTHOR "Author" #define IsPlayer(%1)    ( 1 <= %1 <= g_iMaxPlayers ) new Float: g_iPlrKillTime[ 33 ][ 6 ] new g_iMaxPlayers public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         RegisterHam( Ham_Killed, "player", "_fwHamKilled", .Post = true )         g_iMaxPlayers = get_maxplayers( ) } public _fwHamKilled( iVictim, iKiller ) {     // check if the killer is a player     if( !IsPlayer( iKiller ) )         return             // check if there's an empty cell in the array     for( new i; i < 6; i ++ )     {         if( !g_iPlrKillTime[ iKiller ][ i ] )         {             // there was an empty cell             g_iPlrKillTime[ iKiller ][ i ] = get_gametime( )                         // if this was the last cell of the array, the player has already made 6 kills, so we can skip to checking the time             if( i == 5 )                 goto __CheckTimes                         // the player hasn't killed 6 players yet, so this is our stop             return         }     }         // this code only occurs when the array was already filled. We're shifting the whole array down one cell and filling the last cell with new time     // better way to shift the array? I know this could be done using a loop, but is there a native?     g_iPlrKillTime[ iKiller ][ 0 ] = g_iPlrKillTime[ iKiller ][ 1 ]     g_iPlrKillTime[ iKiller ][ 1 ] = g_iPlrKillTime[ iKiller ][ 2 ]     g_iPlrKillTime[ iKiller ][ 2 ] = g_iPlrKillTime[ iKiller ][ 3 ]     g_iPlrKillTime[ iKiller ][ 3 ] = g_iPlrKillTime[ iKiller ][ 4 ]     g_iPlrKillTime[ iKiller ][ 4 ] = g_iPlrKillTime[ iKiller ][ 5 ]     g_iPlrKillTime[ iKiller ][ 5 ] = get_gametime( )     // time checking __CheckTimes:     // if the time between first kill and last kill is greater than zero and less than 15, the last 6 kills of the player were in the range of 15 seconds.     if( 0.0 < ( g_iPlrKillTime[ iKiller ][ 5 ] - g_iPlrKillTime[ iKiller ][ 0 ] ) <= 15.0 )     {         //code     } }

What this code does is cache the last 6 kills of a player, then check if the time between the first and 6th kill is 15 seconds or less.

Last edited by Backstabnoob; 03-09-2013 at 09:31.
Backstabnoob is offline
bboygrun
CHOMP
Join Date: May 2010
Location: France
Old 03-09-2013 , 09:19   Re: Kill 6 players in 15 seconds
Reply With Quote #10

Quote:
When the player kills 3 people 5 seconds before the timer ends and kills other 3 people right after the timer ends, he would still kill 6 people under 15 seconds but your method wouldn't recognize it.
No, we would kill 6 people in 15 + X seconds, so it isn't recognized and it's normal.

Oh ok i understood (i think) what you want, here you go :

PHP Code:
#include < amxmodx >
#include < hamsandwich >

#define MAX_PLAYERS    32

#define VERSION     "1.0.0"

new Floatg_fPlayerTimeMAX_PLAYERS ];
new 
g_iPlayerKillsMAX_PLAYERS ];

public 
plugin_init( ) 
{
    
register_plugin"Catch Kills"VERSION"Bboy" );
    
    
RegisterHamHam_Killed"player""CPlayer__Killed_P"true );
}

public 
client_disconnectiPlayer )
{
    
g_fPlayerTimeiPlayer ] = 0.0;
}

public 
CPlayer__Killed_P( const iVictim, const iAttacker )
{
    if( 
<= iAttacker <= MAX_PLAYERS )
    {
        new const 
FloatfCurrentTime get_gametime( );
        
        if( 
fCurrentTime g_fPlayerTimeiAttacker ] <= 15.0 )
        {
            if( ++ 
g_iPlayerKillsiAttacker ] == )
            {
                
CPlayer__KillsDoneiAttacker );
            }
        }
        else
        {
            
g_iPlayerKillsiAttacker ] = 1;
        }
        
        
g_fPlayerTimeiAttacker ] = fCurrentTime;
    }
}

CPlayer__KillsDone( const iPlayer )
{
    
// Code

EDIT : You just want to extend the timer after a kill right ? Then if a player do a kill 1 second before timer end, he can do a kill 14 second later and it will count, right ?
__________________

Last edited by bboygrun; 03-09-2013 at 09:23.
bboygrun 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 21:48.


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