Raised This Month: $ Target: $400
 0% 

Block knife attack


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 12-27-2006 , 15:23   Re: Block knife attack
Reply With Quote #1

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 #2

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
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 22:22.


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