AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How do i get user headshot ? (https://forums.alliedmods.net/showthread.php?t=95180)

ƒa†es™ 06-20-2009 15:07

How do i get user headshot ?
 
1. How do i get user headshot ?

2. How do i get user total damage ?

3. How do i get user bomb kill ?

4. How do i get user knife kill ?

Owyn 06-20-2009 15:28

Re: How do i get user headshot ?
 
1. get_tr(TR_iHitgroup) or get_user_attacker() or just DeathMsg if need only killing headshot, it's a param for deathmsg
2. ham_takedamage
3. ham_takedamage damage type param
4. DeathMsg and get_user_attacker()

One 06-20-2009 15:34

Re: How do i get user headshot ?
 
heh ? bomb kill : ham_takedamage damage type param ??

hmmm... r sure? this sound a little wrong :-?

IneedHelp 06-20-2009 15:39

Re: How do i get user headshot ?
 
@ One
http://forums.alliedmods.net/showpos...3&postcount=24

ƒa†es™ 06-21-2009 01:16

Re: How do i get user headshot ?
 
Quote:

Originally Posted by IneedHelp (Post 853048)

Still don't get it.

Please show some code.

hleV 06-21-2009 05:13

Re: How do i get user headshot ?
 
Code:
#include <amxmodx>   public plugin_init() {         register_event("Damage", "eventDamage", "b", "2!0", "3=0", "4!0");         register_event("DeathMsg", "eventDeathMsg", "a", "1>0"); }   public eventDamage(iCl) {         // iDmg now holds the amount of damage done         new iDmg = read_data(2); }   public eventDeathMsg() {         new iHeadShot, szWeap[6];         read_data(3, iHeadShot);         read_data(4, szWeap, 5);           if (iHeadShot)         {                 // Head Shot was made         }           if (equal(szWeap, "knife"))         {                 // Knife kill was made         } }
Sorry, but can't help you with bomb.

Bugsy 06-21-2009 11:29

Re: How do i get user headshot ?
 
Quote:

Originally Posted by hleV (Post 853338)
Code:
        read_data(3, iHeadShot);

Typo: passing 2 params in read_data makes it expect a float byref.

I added victim\killer just in case you need to access them.
Code:
public eventDeathMsg() {         //static iKiller; iKiller = read_data( 1 );         //static iVictim; iVictim = read_data( 2 );         static szWeap[5]; read_data( 4 , szWeap , 4 );         if ( read_data( 3 ) )         {                 // Head Shot was made         }           if ( ( szWeap[ 0 ] == 'k' ) && ( szWeap[ 3 ] == 'f' ) )         {                 // Knife kill was made         } }

ƒa†es™ 06-21-2009 11:41

Re: How do i get user headshot ?
 
Quote:

Originally Posted by Bugsy (Post 853498)
Typo: passing 2 params in read_data makes it expect a float byref.

I added victim\killer just in case you need to access them.

Code:
</p><p>public eventDeathMsg()</p><p>{</p><p> //static iKiller; iKiller = read_data( 1 );</p><p> //static iVictim; iVictim = read_data( 2 );</p><p> static szWeap[5]; read_data( 4 , szWeap , 4 );</p><p>&nbsp;</p><p> if ( read_data( 3 ) )</p><p> {</p><p> // Head Shot was made</p><p> }</p><p>&nbsp;</p><p> if ( ( szWeap[ 0 ] == 'k' ) && ( szWeap[ 3 ] == 'f' ) )</p><p> {</p><p> // Knife kill was made</p><p> }</p><p>}

Can i ask something ?

what is this :

// Head Shot was made

Do i have to do something ?

Bugsy 06-21-2009 11:44

Re: How do i get user headshot ?
 
Quote:

Originally Posted by ƒa†es™ (Post 853506)
Can i ask something ?

what is this :

// Head Shot was made

Do i have to do something ?

That is a comment, it is letting you know that is the location where you put your code to react when a headshot was made.. as you asked for in your original post.

Here is bomb kill
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

new g_iMaxPlayers;

#define IsEntity(%1) (%1 > g_iMaxPlayers)

public plugin_init() 
{
    
register_plugin"Death by Bomb" "1.0" "bugsy" )
    
RegisterHamHam_Killed "player" "fw_HamKilled" );
    
    
g_iMaxPlayers get_maxplayers();
}

public 
fw_HamKillediVictim iKiller iShouldGib )
{
    static 
szKiller[21];
    
    if ( 
IsEntityiKiller ) )
    {
        
peviKiller pev_classname szKiller 20 );
        
        
//env_explosion
        
if ( ( szKiller] == 'e' ) && ( szKiller] == 'v' ) && ( szKiller] == 'x' ) && ( szKiller] == 's' ) )
        {
            
//iVictim was killed by C4 bomb
        
}
    }



Bugsy 06-21-2009 11:47

Re: How do i get user headshot ?
 
Quote:

Originally Posted by ƒa†es™ (Post 853506)
Can i ask something ?

what is this :

// Head Shot was made

Do i have to do something ?

That is where you put your own code which will be called when a headshot was made .. as you requested in your original post.

Here is bomb kill. You can also use this for detecting knife-kill with some modification.
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

new g_iMaxPlayers;

#define IsEntity(%1) (%1 > g_iMaxPlayers)

public plugin_init() 
{
    
register_plugin"Death by Bomb" "1.0" "bugsy" )
    
RegisterHamHam_Killed "player" "fw_HamKilled" );
    
    
g_iMaxPlayers get_maxplayers();
}

public 
fw_HamKillediVictim iKiller iShouldGib )
{
    static 
szKiller21 ];
    
    if ( 
IsEntityiKiller ) )
    {
        
peviKiller pev_classname szKiller 20 );
        
        
//env_explosion
        
if ( ( szKiller] == 'e' ) && ( szKiller] == 'v' ) && ( szKiller] == 'x' ) && ( szKiller] == 's' ) )
        {
            
//iVictim was killed by C4 bomb
        
}
    }




All times are GMT -4. The time now is 15:34.

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