Raised This Month: $32 Target: $400
 8% 

Show entity's health when aiming.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tribadist
Junior Member
Join Date: Dec 2008
Location: WAN
Old 03-29-2012 , 06:27   Show entity's health when aiming.
Reply With Quote #1

Hey,

To put it shortly: I've searched and tried a lot (tutorials, forums, other plugins) to make this plugin show entity's (in this case lasermine's) health when aiming at it. That's what I've tried to do:

Code:
set_task(1.0, showhp) - goes into public plugin_init ()

public showhp(id)
{
    new tgt,body;
        if(is_user_connected(id))
    get_user_aiming(id,tgt,body);
    if(!pev_valid(tgt)) return;
    
    new EntityName[32];
    pev(tgt, pev_classname, EntityName, 31);
    if(!equal(EntityName, ENT_CLASS_NAME)) return;
    
        new i_Ent = engfunc(EngFunc_CreateNamedEntity,g_EntMine);
        new iLMHP = pev(i_Ent, pev_health)
        client_print( id, print_chat, "%i", iLMHP);  

    return;
}
It does compile and loads without errors, but doesn't show any health when aimint at a lasermine.

Would appreciate any help.
tribadist is offline
Send a message via ICQ to tribadist Send a message via MSN to tribadist
Old 03-29-2012, 06:43
tuty
This message has been deleted by tuty. Reason: wrong lol
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 03-29-2012 , 08:30   Re: Show entity's health when aiming.
Reply With Quote #2

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

public client_putinserveriClient )
{
  
set_task1.0"Task_CheckAiming"iClient 3389__"b" );
}

public 
client_disconnectiClient )
{
  
remove_taskiClient 3389 );
}

public 
Task_CheckAimingiTaskIndex )
{
// http://forums.alliedmods.net/showpost.php?p=835030

  
if( is_user_aliveiTaskIndex 3389 ) )
  {
    static 
iEntityFloatfClientOrigin], FloatfClientFrontEndOrigin], iTraceResult;

    
engfuncEngFunc_TraceLine, ... ); // see tutorial...

    
if( pev_validiEntity ) )
    {
      
HUDMESSAGEiTaskIndex 3389 /* Which means the client index */"Health: %i"peviEntitypev_health ) );
    }
  }


Last edited by claudiuhks; 03-29-2012 at 08:32.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
tribadist
Junior Member
Join Date: Dec 2008
Location: WAN
Old 03-29-2012 , 13:37   Re: Show entity's health when aiming.
Reply With Quote #3

Thanks for the fast reply. So you've made a separate plugin. I've read the tutorial you gave a link for, but still couldn't get it, what should I put here:
Code:
engfunc( EngFunc_TraceLine, ... ); // see tutorial...
Do I just insert these parameters:
Code:
 static iEntity, Float: fClientOrigin[ 3 ], Float: fClientFrontEndOrigin[ 3 ], iTraceResult; 
?

I can't get the meaning of all the parameters of function - EngFunc_TraceLine

The original idea is THIS
Maybe its easier to do this thing without aiming, but just show lasermine health as a HUD message constantly?
tribadist is offline
Send a message via ICQ to tribadist Send a message via MSN to tribadist
tuty
Veteran Member
Join Date: Jul 2008
Location: UK
Old 03-29-2012 , 15:02   Re: Show entity's health when aiming.
Reply With Quote #4

lool just use FM_TraceLine...


Code:
register_forward( FM_TraceLine, "forward_TraceLine", 1 ); public forward_TraceLine( Float:v1[ 3 ], Float:v2[ 3 ], fNoMonsters, entToSkip, iTr ) {     static iTr;     iTr = get_tr2( iTr, TR_pHit );     if( pev_valid( iTr ) )     {         static szClassname[ 32 ];         pev( iTr, pev_classname, szClassname, charsmax( szClassname ) );         if( equal( szClassname, "your entity classname here" ) )         {             static Float:flHealth;             pev( iTr, pev_health, flHealth );                         client_print( entToSkip, print_center, "Entity health: %d", floatround( flHealth ) );         }     } }
__________________
tuty is offline
Send a message via ICQ to tuty Send a message via AIM to tuty
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 03-29-2012 , 18:30   Re: Show entity's health when aiming.
Reply With Quote #5

Sorry, but , What is TraceLine ( a little simple description )? when its called ? and when its better to use?
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
tribadist
Junior Member
Join Date: Dec 2008
Location: WAN
Old 03-30-2012 , 01:40   Re: Show entity's health when aiming.
Reply With Quote #6

Thanks tuty. I inserted this FM_Traceline forward into the plugin I mentioned in the first post. It compiled successfully, but now the server goes into an infinite loop of restarts. No logs, no errors. Did I get it right: you just register this forward and then input forward's body (public forward_traceline {...} ) into a random place in the code? or should I choose a specific place for it?

Last edited by tribadist; 03-30-2012 at 01:41. Reason: Typo
tribadist is offline
Send a message via ICQ to tribadist Send a message via MSN to tribadist
tuty
Veteran Member
Join Date: Jul 2008
Location: UK
Old 03-30-2012 , 06:24   Re: Show entity's health when aiming.
Reply With Quote #7

have you edit this line?

Code:
if( equal( szClassname, "your entity classname here" ) )         {
__________________
tuty is offline
Send a message via ICQ to tuty Send a message via AIM to tuty
tribadist
Junior Member
Join Date: Dec 2008
Location: WAN
Old 03-30-2012 , 06:31   Re: Show entity's health when aiming.
Reply With Quote #8

Quote:
Originally Posted by tuty View Post
have you edit this line?

Code:
if( equal( szClassname, "your entity classname here" ) ) {
Sure. In the original .sma is says:
Code:
new const
    ENT_CLASS_NAME[]    = "lasermine",
    //ENT_CLASS_NAME2[]    = "info_target",
    ENT_CLASS_NAME3[]    = "func_breakable";
So, I put it this way: if( equal( szClassname, ENT_CLASS_NAME ) )

Any other ideas?
tribadist is offline
Send a message via ICQ to tribadist Send a message via MSN to tribadist
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 03-30-2012 , 06:58   Re: Show entity's health when aiming.
Reply With Quote #9

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

public client_putinserveriClient )
{
  
set_task1.0"Task_CheckAiming"iClient 3389__"b" );
}

public 
client_disconnectiClient )
{
  
remove_taskiClient 3389 );
}

public 
Task_CheckAimingiTaskIndex )
{
  static 
iClient;
  
iClient iTaskIndex 3389;

  if( 
is_user_aliveiClient ) )
  {
    static 
iEntityiDummycClassname32 ];
    
get_user_aimingiClientiEntityiDummy9999 );

    if( 
pev_validiEntity ) )
    {
      
peviEntitypev_classnamecClassname31 );

      if( 
equalcClassname"YOUR_CLASS_NAME" ) )
      {
        
// YOUR_PRINT_FUNCTION( iClient, "Health: %i", pev( iEntity, pev_health ) );
      
}
    }
  }


Last edited by claudiuhks; 03-30-2012 at 06:58.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
tuty
Veteran Member
Join Date: Jul 2008
Location: UK
Old 03-30-2012 , 07:01   Re: Show entity's health when aiming.
Reply With Quote #10

dude, using a task for such a think isnt a good idea :/

my code works fine if you use it wisely
__________________

Last edited by tuty; 03-30-2012 at 07:01.
tuty is offline
Send a message via ICQ to tuty Send a message via AIM to tuty
Reply


Thread Tools
Display Modes

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 05:59.


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