Raised This Month: $ Target: $400
 0% 

Retriving shield hit


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bomnacama
Senior Member
Join Date: Dec 2008
Location: Portugal
Old 02-07-2009 , 05:09   Retriving shield hit
Reply With Quote #1

Hi!

Im having an hard time founding a way of retriving if an player as been hit in the shield
__________________



Please FEED MY HAMSTERS by giving me +karma
bomnacama is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 02-07-2009 , 13:43   Re: Retriving shield hit
Reply With Quote #2

Try this:

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

#define VERSION    "1.0"

public plugin_init()
{
    
register_plugin("Hook Shield Hit"VERSION"Dores");
    
    
register_forward(FM_TraceLine"Forward_TraceLine"1); // Post. Removed the last parameter to catch the hit BEFORE it happened.
}

public 
Forward_TraceLine(Float:v1[3], Float:v2[3], noMonstersenttoskiptr)
{
    static 
HitszClass[22];
    
Hit get_tr2(trTR_pHit);
    
    
pev(Hitpev_classnameszClass21);
    
    if(
equal(szClass"weapon_shield"))
    {
        
client_print(0print_chat"[TEST] Shield was hit!");
        
        static 
pOwn;
        
pOwn pev(Hitpev_owner); // Retrieve shield's owner.
    
}
    
    return 
FMRES_IGNORED;

__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
bomnacama
Senior Member
Join Date: Dec 2008
Location: Portugal
Old 02-07-2009 , 19:02   Re: Retriving shield hit
Reply With Quote #3

I get this from debug

L 02/07/2009 - 23:595: Start of error session.
L 02/07/2009 - 23:595: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20090207.log")
L 02/07/2009 - 23:595: [FAKEMETA] Invalid entity
L 02/07/2009 - 23:595: [AMXX] Displaying debug trace (plugin "teste.amxx")
L 02/07/2009 - 23:595: [AMXX] Run time error 10: native error (native "pev")
L 02/07/2009 - 23:595: [AMXX] [0] textV1T8F9.sma::Forward_TraceLine (line 18
L 02/07/2009 - 23:595: [FAKEMETA] Invalid entity

and I get this when I compile, but it still compils good

/home/groups/amxmodx/tmp3/textInEZG5.sma(26) : warning 204: symbol is assigned a value that is never used: "pOwn"
__________________



Please FEED MY HAMSTERS by giving me +karma

Last edited by bomnacama; 02-07-2009 at 19:04.
bomnacama is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 02-07-2009 , 19:27   Re: Retriving shield hit
Reply With Quote #4

PHP Code:
if( !pev_valiedHit ) ) return FMRES_IGNORED
With this you won't get that error anymore. But still so, i think it won't work.
__________________

anakin_cstrike is offline
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 02-07-2009 , 20:28   Re: Retriving shield hit
Reply With Quote #5

Tested and works.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define HIT_SHIELD 8

public plugin_init() 
{
    
register_plugin("PLUGIN""VERSION""AUTHOR")
    
register_forward(FM_TraceLine"fw_Traceline"1)
}

public 
fw_Traceline(Float:start[3], Float:end[3], nomonstersidtrace

    if(!
is_user_connected(id)) 
        return 
FMRES_IGNORED
    
    static 
victimhitgroup
    victim 
get_tr2(traceTR_pHit);
    
hitgroup get_tr2(traceTR_iHitgroup); 

    if(!
is_user_connected(victim)) 
        return 
FMRES_IGNORED

    if (
hitgroup == HIT_SHIELD)
        
client_print(idprint_chat"Shield Hit")
    
    return 
FMRES_IGNORED

Whenever you aim/shoot at a shield. The script triggers.

http://forums.alliedmods.net/showthread.php?t=51181
__________________
It's a mystery.
Mini_Midget is offline
bomnacama
Senior Member
Join Date: Dec 2008
Location: Portugal
Old 02-08-2009 , 17:20   Re: Retriving shield hit
Reply With Quote #6

working good ty
__________________



Please FEED MY HAMSTERS by giving me +karma
bomnacama is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-09-2009 , 01:27   Re: Retriving shield hit
Reply With Quote #7

Would Ham_TraceAttack, "weapon_shield" work ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-09-2009 , 05:06   Re: Retriving shield hit
Reply With Quote #8

No, nor "player".

But 'IsHittingShield()' is called at the top of this forward, when you look into the game binary.
Arkshine is offline
bomnacama
Senior Member
Join Date: Dec 2008
Location: Portugal
Old 02-11-2009 , 11:34   Re: Retriving shield hit
Reply With Quote #9

his code works great but i failed to make a way that gives me the location of the hit, so I can add an effect
__________________



Please FEED MY HAMSTERS by giving me +karma
bomnacama is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 02-11-2009 , 12:36   Re: Retriving shield hit
Reply With Quote #10

Quote:
Originally Posted by bomnacama View Post
his code works great but i failed to make a way that gives me the location of the hit, so I can add an effect
victim is the shield holder. So... probably something like this:
Code:
new Float:origin[3];
pev(victim, pev_origin, origin);
SnoW is offline
Send a message via MSN to SnoW
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 17:03.


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