AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Retriving shield hit (https://forums.alliedmods.net/showthread.php?t=85190)

bomnacama 02-07-2009 05:09

Retriving shield hit
 
Hi!

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

Dores 02-07-2009 13:43

Re: Retriving shield hit
 
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;



bomnacama 02-07-2009 19:02

Re: Retriving shield hit
 
I get this from debug

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

anakin_cstrike 02-07-2009 19:27

Re: Retriving shield hit
 
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.

Mini_Midget 02-07-2009 20:28

Re: Retriving shield hit
 
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

bomnacama 02-08-2009 17:20

Re: Retriving shield hit
 
working good ty :D

ConnorMcLeod 02-09-2009 01:27

Re: Retriving shield hit
 
Would Ham_TraceAttack, "weapon_shield" work ?

Arkshine 02-09-2009 05:06

Re: Retriving shield hit
 
No, nor "player".

But 'IsHittingShield()' is called at the top of this forward, when you look into the game binary.

bomnacama 02-11-2009 11:34

Re: Retriving shield hit
 
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

SnoW 02-11-2009 12:36

Re: Retriving shield hit
 
Quote:

Originally Posted by bomnacama (Post 759907)
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);



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

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