AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Block knife attack (https://forums.alliedmods.net/showthread.php?t=49055)

Boop 12-26-2006 13:52

Block knife attack
 
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 12-27-2006 08:26

Re: Block knife attack
 
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 :)

Simon Logic 12-27-2006 08:44

Re: Block knife attack
 
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.

Boop 12-27-2006 09:16

Re: Block knife attack
 
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

Simon Logic 12-27-2006 09:39

Re: Block knife attack
 
It's a C++. Right now I have no time to explain. I just gave you a main idea. Thought you'll get it.

The Specialist 12-27-2006 09:51

Re: Block knife attack
 
Quote:

Originally Posted by Simon Logic (Post 420492)
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 ?

Boop 12-27-2006 10:18

Re: Block knife attack
 
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 ?

XxAvalanchexX 12-27-2006 15:23

Re: Block knife attack
 
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).

Boop 12-28-2006 06:12

Re: Block knife attack
 
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

XxAvalanchexX 12-28-2006 18:52

Re: Block knife attack
 
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);


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

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