AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How do I get when 2 players were stabbed at the same time? (https://forums.alliedmods.net/showthread.php?t=94355)

alan_el_more 06-10-2009 09:16

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

xPaw 06-10-2009 09:21

Re: How do I get when 2 players were stabbed at the same time?
 
TakeDamage, get_gametime() :)

EDIT: Hai bugsy

Bugsy 06-10-2009 09:21

Re: How do I get when 2 players were stabbed at the same time?
 
Check get_gametime() and weapons at ham_takedamage

Edit: xPaw FTW

alan_el_more 06-10-2009 09:25

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

Bugsy 06-10-2009 09:42

Re: How do I get when 2 players were stabbed at the same time?
 
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" );
    }



Bugsy 06-10-2009 10:06

Re: How do I get when 2 players were stabbed at the same time?
 
Edited above code


All times are GMT -4. The time now is 13:54.

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