Raised This Month: $51 Target: $400
 12% 

Block knife attack


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Boop
Junior Member
Join Date: Dec 2006
Old 12-26-2006 , 13:52   Block knife attack
Reply With Quote #1

Hi,

To make someone invulnerable for some players , i see that there are two methods :

- Traceline
- Set_user_hitzones

Nevertheless, I Have one problem, people aren't protect against knife or nade attacks. Is there a mean to block damage done by some players with knife or nades ???

Tks U
Boop is offline
Boop
Junior Member
Join Date: Dec 2006
Old 12-27-2006 , 08:26   Re: Block knife attack
Reply With Quote #2

After a search, one solution to this problem seems to be trace_hull. People tells that this function is adapted but I don't find example of its use.

Somebody can tell me (knows) how use this function (trace_hull) to solve my problem ?

Tks
Boop is offline
Simon Logic
Senior Member
Join Date: Nov 2006
Location: RF
Old 12-27-2006 , 08:44   Re: Block knife attack
Reply With Quote #3

Override TraceLine function with register_forward().

Here is an example from AXN how to disable a HEADSHOT.
Code:
void TraceLine(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr)
{
    TRACE_LINE(v1, v2, fNoMonsters, pentToSkip, ptr);
    if(ptr->iHitgroup == HITGROUP_HEAD && axn_noheadshot->value != 0)
    {
        ptr->iHitgroup = HITGROUP_GENERIC;
    }
    RETURN_META(MRES_SUPERCEDE);
}
You have to just hack a trace result structure for your own needs.
Simon Logic is offline
Send a message via Skype™ to Simon Logic
Boop
Junior Member
Join Date: Dec 2006
Old 12-27-2006 , 09:16   Re: Block knife attack
Reply With Quote #4

Maybe I'm stupid but i don't understand what u say. Your code isn't a Pawn Code ??

I try to block knife attack from some people against specific others. I've read that i need to use trace_hull (because traceline isn't the solution to block melee attack) but I don't know how to use this function in my case ? I don't understand how your post answer to this ? Can u explain please ?

Thank you
Boop is offline
Simon Logic
Senior Member
Join Date: Nov 2006
Location: RF
Old 12-27-2006 , 09:39   Re: Block knife attack
Reply With Quote #5

It's a C++. Right now I have no time to explain. I just gave you a main idea. Thought you'll get it.
Simon Logic is offline
Send a message via Skype™ to Simon Logic
The Specialist
BANNED
Join Date: Nov 2006
Old 12-27-2006 , 09:51   Re: Block knife attack
Reply With Quote #6

Quote:
Originally Posted by Simon Logic View Post
It's a C++. Right now I have no time to explain. I just gave you a main idea. Thought you'll get it.
why would you post C++ code ?
The Specialist is offline
Send a message via AIM to The Specialist
Boop
Junior Member
Join Date: Dec 2006
Old 12-27-2006 , 10:18   Re: Block knife attack
Reply With Quote #7

Thank you but I think that it will be hard (for me) to do something with this C++ code for a plugin ... written in Pawn.

However, someone can explain how to use trace_hull to solve my problem or if it's too long, someone can give me reference of plugins which use trace_hull ?
Boop is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 12-27-2006 , 15:23   Re: Block knife attack
Reply With Quote #8

Try something like this.

Code:
new knifeImmune[33]; public plugin_init() {     register_forward(FM_TraceHull,"fw_tracehull"); } public fw_tracehull(Float:v1[3],Float:v2[3],noMonsters,hull,skipEnt,ptr); {     // not a player, or a dead one     if(!is_user_connected(skipEnt) || !is_user_alive(skipEnt))         return FMRES_IGNORED;     static hit;     hit = get_tr(TR_pHit);     // an immune player was not hit     (!hit || hit > 32 || !knifeImmune[hit])         return FMRES_IGNORED;     // override     set_tr(TR_pHit,0);     return FMRES_IGNORED; }

It hooks trace_hull, and if a player that should be knife immune is getting hit by it, it overrides it and says that instead, no one is getting hit by it. If you want to check the attacker, use skipEnt (but make sure it is a player).
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Boop
Junior Member
Join Date: Dec 2006
Old 12-28-2006 , 06:12   Re: Block knife attack
Reply With Quote #9

I tried this (everyone is immune) :

Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

new bool:knifeImmune[33] = true;

public plugin_init() {
    register_forward(FM_TraceHull,"fw_tracehull");
}

 public fw_tracehull(Float:v1[3],Float:v2[3],noMonsters,hull,skipEnt,ptr) {    
     
    if(!is_user_connected(skipEnt) || !is_user_alive(skipEnt))
        return FMRES_IGNORED;
    
    static hit;
    hit = get_tr(TR_pHit);     // an immune player was not hit  

    if (!hit || hit > 32 || !knifeImmune[hit])      
        return FMRES_IGNORED;     // override  
        
    set_tr(TR_pHit,0);  
    return FMRES_IGNORED;

}
This isn't working : everyone can kill with knife.

I make a test :

When script pass the first condition and get hit, the only hit returned is "-1". I think that it's not a value wanted. No ? Do u know why we have only -1 ?

Thank u

Last edited by Boop; 12-28-2006 at 06:15.
Boop is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 12-28-2006 , 18:52   Re: Block knife attack
Reply With Quote #10

Either the trace isn't getting stored in the global trace handler, or I don't quite understand hull traces. Try changing the get_tr line to this:

Code:
hit = get_tr2(ptr,TR_pHit);
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Old 12-28-2006, 19:15
Iznogood
This message has been deleted by Iznogood. Reason: Error
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 21:21.


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