Raised This Month: $ Target: $400
 0% 

TR_Trace


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 01-31-2010 , 20:23   TR_Trace
Reply With Quote #1

Is their a way to do something like the follwing using a switch.

In source mod i know i had to set the values from 0 = false then 1 - 4 = true.. never done this with amx modx. so i have no idea how it works.

PHP Code:
//==============================================================//
//                        *******************                        //
//                        *    Cvar  Values  *                        //
//                        *******************                        //
//    nhs_mode 1 Blocks bots from shooting humans in the head     //
//    nhs_mode 2 Blocks all headshots (Humans and bots)           //
//    nhs_mode 3 Headshots Only (blocks all other hitzones)       //
//    nhs_mode 4 Redirects all hitzones to the head               //
//==============================================================//    

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

new modebool:gBotsRegistered;

public 
plugin_init()
{
    
register_plugin("No Headshot""1.0""=(GrG)=");
    
RegisterHam(Ham_TraceAttack"player""HamTraceAttack");
    
    
mode register_cvar("nhs_mode""2");
}

public 
client_authorizedid )
{
    if( !
gBotsRegistered && is_user_botid ) )
    {
        
set_task0.1"register_bots"id );
    }
}

public 
register_botsid )
{
    if( !
gBotsRegistered && is_user_connectedid ) )
    {
        
RegisterHamFromEntityHam_TraceAttackid"HamTraceAttack");
        
gBotsRegistered true;
    }
}

public 
HamTraceAttack(VicAttFloat:dmgFloat:dir[3], traceresultdmgbits)
{
    new 
Nhs_Modes get_pcvar_num(mode);
    
    switch(
Nhs_Modes)
    {
        case 
1:
        {
            if(!
is_user_bot(Vic) && is_user_bot(Att))
            {
                if(
get_tr2(traceresultTR_iHitgroup) == HIT_HEAD)
                {
                    
//set_tr2(traceresult, TR_iHitgroup, HIT_CHEST) //uncomment to make headshots hit the chest
                    
return HAM_HANDLED
                
}
            }
        }
        case 
2:
        {
            if(
get_tr2(traceresultTR_iHitgroup) == HIT_HEAD)
            {
                
//set_tr2(traceresult, TR_iHitgroup, HIT_CHEST) //uncomment to make headshots hit the chest
                
return HAM_HANDLED
            
}
        }
        case 
3:
        {
            if(
get_tr2(traceresultTR_iHitgroup) != HIT_HEAD)
            {
                return 
HAM_HANDLED
            
}
        }
        case 
4:
        {
            if(
get_tr2(traceresultTR_iHitgroup) != HIT_HEAD)
            {
                
set_tr2(traceresultTR_iHitgroupHIT_HEAD//uncomment to make headshots hit the chest
                
return HAM_HANDLED
            
}
        }
    }
    return 
HAM_IGNORED;

Doc-Holiday is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-31-2010 , 23:20   Re: TR_Trace
Reply With Quote #2

Not sure if this is what you're looking for

PHP Code:
new Nhs_Modes get_pcvar_num(mode);

switch(
Nhs_Modes)
{
    case 
0//0 - false
    
{
        
    }
    default: 
//All other values - true
    
{
        
    }

Or you can do

PHP Code:
new Nhs_Modes get_pcvar_num(mode);
    
if ( !
Nhs_Modes )
    return 
HAM_IGNORED;

//code 
__________________

Last edited by Bugsy; 01-31-2010 at 23:46.
Bugsy is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 01-31-2010 , 23:55   Re: TR_Trace
Reply With Quote #3

The switch each case 0-4 are different

How ever if i set the value to anything nothing happens.
Doc-Holiday is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-31-2010 , 23:59   Re: TR_Trace
Reply With Quote #4

Have you tried the above?
__________________
Bugsy is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-01-2010 , 00:24   Re: TR_Trace
Reply With Quote #5

If only you would say what the plugin is supposed to do
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 02-01-2010 , 00:31   Re: TR_Trace
Reply With Quote #6

Quote:
Originally Posted by Bugsy View Post
Have you tried the above?
//============================================= =================//
// ******************* //
// * Cvar Values * //
// ******************* //
// nhs_mode 1 Blocks bots from shooting humans in the head //
// nhs_mode 2 Blocks all headshots (Humans and bots) //
// nhs_mode 3 Headshots Only (blocks all other hitzones) //
// nhs_mode 4 Redirects all hitzones to the head //
//============================================= =================//


For some reason.... ive been working on it. but the values of nhs_mode. is what seem like their not getting checked.

Last edited by Doc-Holiday; 02-01-2010 at 00:34.
Doc-Holiday is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-01-2010 , 06:46   Re: TR_Trace
Reply With Quote #7

Only mode 4 was ok.
If you redirect the shot return HAM_HANDLED.
If you want to stop the function, use HAM_SUPERCEDE (or set the trace to HIT_GENERIC)

PHP Code:
//==============================================================//
//                        *******************                        //
//                        *    Cvar  Values  *                        //
//                        *******************                        //
//    nhs_mode 1 Blocks bots from shooting humans in the head     //
//    nhs_mode 2 Blocks all headshots (Humans and bots)           //
//    nhs_mode 3 Headshots Only (blocks all other hitzones)       //
//    nhs_mode 4 Redirects all hitzones to the head               //
//==============================================================//    

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

new modebool:gBotsRegistered;

public 
plugin_init()
{
    
register_plugin("No Headshot""1.0""=(GrG)=");
    
RegisterHam(Ham_TraceAttack"player""HamTraceAttack");
    
    
mode register_cvar("nhs_mode""2");
}

public 
client_authorizedid )
{
    if( !
gBotsRegistered && is_user_botid ) )
    {
        
set_task0.1"register_bots"id );
    }
}

public 
register_botsid )
{
    if( !
gBotsRegistered && is_user_connectedid ) )
    {
        
RegisterHamFromEntityHam_TraceAttackid"HamTraceAttack");
        
gBotsRegistered true;
    }
}

public 
HamTraceAttack(VicAttFloat:dmgFloat:dir[3], traceresultdmgbits)
{
    new 
Nhs_Modes get_pcvar_num(mode);
    
    switch(
Nhs_Modes)
    {
        case 
1// Blocks bots from shooting humans in the head
        
{
            if(!
is_user_bot(Vic) && is_user_bot(Att))
            {
                if(
get_tr2(traceresultTR_iHitgroup) == HIT_HEAD)
                {
                 
//   set_tr2(traceresult, TR_iHitgroup, HIT_CHEST) //uncomment to make headshots hit the chest
                 //   return HAM_HANDLED // HANDLED doesn't stop anything
                    
return HAM_SUPERCEDE
                
}
            }
        }
        case 
2// Blocks all headshots (Humans and bots)
        
{
            if(
get_tr2(traceresultTR_iHitgroup) == HIT_HEAD)
            {
                
//set_tr2(traceresult, TR_iHitgroup, HIT_CHEST) //uncomment to make headshots hit the chest
                //return HAM_HANDLED
                
return HAM_SUPERCEDE
            
}
        }
        case 
3// Headshots Only (blocks all other hitzones) 
        
{
            if(
get_tr2(traceresultTR_iHitgroup) != HIT_HEAD)
            {
                return 
HAM_SUPERCEDE
            
}
        }
        case 
4:
        {
            if(
get_tr2(traceresultTR_iHitgroup) != HIT_HEAD)
            {
                
//Redirects all hitzones to the head // this one is ok
                
set_tr2(traceresultTR_iHitgroupHIT_HEAD//uncomment to make headshots hit the chest
                
return HAM_HANDLED
            
}
        }
    }
    return 
HAM_IGNORED;

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 02-01-2010 at 06:54.
ConnorMcLeod is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 02-01-2010 , 17:21   Re: TR_Trace
Reply With Quote #8

Thank you sure them damn returns are confusing.... But thank you.
Doc-Holiday 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 07:17.


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