Raised This Month: $ Target: $400
 0% 

How do I get when 2 players were stabbed at the same time?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-10-2009 , 09:42   Re: How do I get when 2 players were stabbed at the same time?
Reply With Quote #5

Untested

Edit: You will probably get no results with the previous code since the time value is float [25.31] and it is very unlikely that two numbers will ever be identical. I edited the code to allow you to specify if the knife attacks happened within g_fKnifeTime seconds from one another then it is considered the same time. Default is 1 second

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

#define PLUGIN "Detect knife at same time"
#define VERSION "1.0"
#define AUTHOR "bugsy"

new Floatg_fKnifeAttacked[33];
new 
g_iMaxPlayers;

const 
Floatg_fKnifeTime 1.0;

#define IsPlayer(%1) ( 1 <= %1 <= g_iMaxPlayers )

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHamHam_TakeDamage "player" "fw_HamTakeDamage" )
    
    
g_iMaxPlayers get_maxplayers();
}

public 
fw_HamTakeDamageiVictim iInflictor iAttacker Float:fDamage iBitDamage )
{
    static 
i;
    
    if ( 
IsPlayeriAttacker ) && ( get_user_weaponiAttacker ) == CSW_KNIFE ) )
    {
        
g_fKnifeAttackediVictim ] = get_gametime();
        
        for ( 
<= g_iMaxPlayers i++ )
            if ( ( 
!= iVictim ) && g_fKnifeAttacked] && ( floatabsg_fKnifeAttacked] - g_fKnifeAttackediVictim ] ) <= g_fKnifeTime ) )
                
client_printiVictim print_chat "Knifed at same time as player id - %d" );
    }

__________________

Last edited by Bugsy; 06-10-2009 at 10:06.
Bugsy is offline
 



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 13:54.


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