AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   No Headshot (https://forums.alliedmods.net/showthread.php?t=94343)

Debesėlis 06-10-2009 05:46

No Headshot
 
How do I make this menu function make you immune to headshots.

PHP Code:

public hs(id)
{
    if(
headshot_active[id] == 1)
    {

//no headshot code...

    
}


I want something simmilar to:
http://forums.alliedmods.net/showthread.php?p=489668

But I don't want to use VESTHELM. After activating the menu function others couldn't do headshots on you.

Arkshine 06-10-2009 05:59

Re: No Headshot
 
Something like :

Code:
    #include <amxmodx>     #include <fakemeta>     #include <hamsandwich>         const m_LastHitGroup = 75;     public plugin_init ()     {         RegisterHam( Ham_TakeDamage, "player", "Event_PlayerTakeDamage" );     }         public Event_PlayerTakeDamage ( const Victim )     {         return headshot_active[ Victim ] && get_pdata_int( Victim, m_LastHitGroup ) == HIT_HEAD ? : HAM_SUPERCEDE : HAM_IGNORED;     }

Debesėlis 06-10-2009 06:53

Re: No Headshot
 
doesn't work

Atspulgs 06-10-2009 08:35

Re: No Headshot
 
heh i once did something similar only for a hero.
i did this
PHP Code:

/* Sets hit zones for player.
 * Parts of body are as bits:
 * 1   - generic
 * 2   - head
 * 4   - chest
 * 8   - stomach
 * 16  - left arm
 * 32  - right arm
 * 64  - left leg
 * 128 - right leg */
native set_user_hitzones(index 0target 0body 255);

/* Get user hitzones. */
native get_user_hitzones(indextarget); 

this you may found in fun.inc
those are syntaxes, and not my code :) (just to make clear)

Debesėlis 06-10-2009 08:49

Re: No Headshot
 
Quote:

Originally Posted by Atspulgs (Post 845516)
heh i once did something similar only for a hero.
i did this
PHP Code:

/* Sets hit zones for player.
 * Parts of body are as bits:
 * 1   - generic
 * 2   - head
 * 4   - chest
 * 8   - stomach
 * 16  - left arm
 * 32  - right arm
 * 64  - left leg
 * 128 - right leg */
native set_user_hitzones(index 0target 0body 255);

/* Get user hitzones. */
native get_user_hitzones(indextarget); 

this you may found in fun.inc
those are syntaxes, and not my code :) (just to make clear)


PHP Code:

public hs(id)
{
    if(
headshot_active[id] == 1)
    {
         
native set_user_hitzones(index 0target 0body 255);
         
native get_user_hitzones(indextarget);

    }


as it should appear? :)

Arkshine 06-10-2009 10:24

Re: No Headshot
 
My code works perfectly. I tested before posting. It doesn't compile because I've added headshot_active[ Victim ] to show you the way, that's all.

Debesėlis 06-10-2009 12:44

Re: No Headshot
 
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
    
const m_LastHitGroup 75;

public 
hs(id, const Victim)
{
    if(
headshot_active[id] == 1)
    {

        return 
headshot_active[Victim] && get_pdata_int(Victimm_LastHitGroup) == HIT_HEAD ? : HAM_SUPERCEDE HAM_IGNORED;

    }


I tried to put it together, but I didn't manage to.

Bugsy 06-10-2009 12:48

Re: No Headshot
 
arkshine had it formatted correctly.

Are you setting the headshot_active array element to 1\true for the player that you want to be immune to headshots?

Edit: Fixed typo in return line

return headshot_active[ Victim ] && get_pdata_int( Victim, m_LastHitGroup ) == HIT_HEAD ? [->] : [<-] HAM_SUPERCEDE : HAM_IGNORED;

PHP Code:


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

new headshot_active33 ];
const 
m_LastHitGroup 75;

public 
plugin_init ()
{
    
RegisterHamHam_TakeDamage"player""Event_PlayerTakeDamage" );
    
    
register_concmd"amx_blockhs" "cmdBlockHS" );
}

public 
cmdBlockHSid )
{
    
headshot_activeid ] = 1;
}

public 
Event_PlayerTakeDamage ( const Victim )

    return ( 
headshot_activeVictim ] && ( get_pdata_intVictimm_LastHitGroup ) == HIT_HEAD  ) ) ? HAM_SUPERCEDE HAM_IGNORED;



joaquimandrade 06-10-2009 12:51

Re: No Headshot
 
PHP Code:


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

const m_LastHitGroup 75;
new 
cvarHeadshot

public plugin_init ()
{
    
RegisterHamHam_TakeDamage"player""Event_PlayerTakeDamage" );
    
    
cvarHeadshot register_cvar("headshot","1")
}

public 
Event_PlayerTakeDamage ( const Victim )

    return 
get_pcvar_numcvarHeadshot ) && ( get_pdata_intVictimm_LastHitGroup ) == HIT_HEAD ) ? HAM_SUPERCEDE HAM_IGNORED;


It's arkshine code. You will also need to take care of the blood.

Debesėlis 06-10-2009 12:55

Re: No Headshot
 
Quote:

Originally Posted by Bugsy (Post 845690)
arkshine had it formatted correctly.

Are you setting the headshot_active array element to 1\true for the player that you want to be immune to headshots?

PHP Code:

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

new headshot_active33 ];
const 
m_LastHitGroup 75;

public 
plugin_init ()
{
    
RegisterHamHam_TakeDamage"player""Event_PlayerTakeDamage" );
    
register_concmd"amx_blockhs" "cmdBlockHS" );
}

public 
cmdBlockHSid )
{
    
headshot_activeid ] = 1;
}

public 
Event_PlayerTakeDamage ( const Victim )

    return 
headshot_activeVictim ] && get_pdata_intVictimm_LastHitGroup ) == HIT_HEAD ? : HAM_SUPERCEDE HAM_IGNORED;




I have an admin menu. I want players who activate the headshot immunity function to be immune to headshots.


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

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