Raised This Month: $ Target: $400
 0% 

hp based glow


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
11922911
Senior Member
Join Date: Dec 2011
Location: Yuen Long Country
Old 01-07-2014 , 00:49   Re: hp based glow
Reply With Quote #1

Just bored to have a quick try.
PHP Code:
#include amxmodx
#include fakemeta
#include hamsandwich

#define IsPlayer(%1) (1 <= %1 <= g_MaxClients)

#define GetBits(%1,%2) (%1 & (1 << (%2 & 31)))
#define SetBits(%1,%2) (%1 |= (1 << (%2 & 31)))
#define ClrBits(%1,%2) (%1 &= ~(1 << (%2 & 31)))

new g_IsAliveg_IsAimingPlayer;
new 
g_RenderTarget[33];
new 
g_PlayerColor[33][3];

new 
g_fnAddToFullPack;
new 
g_MaxClients;

public 
plugin_init()
{
    
register_event("Health""EventHealth""b");
    
    
register_forward(FM_TraceLine"TraceLine_Post"1);
    
    
RegisterHam(Ham_Spawn,  "player""PlayerLife"1);
    
RegisterHam(Ham_Killed"player""PlayerLife"1);
    
    
g_MaxClients get_maxplayers();
}

public 
client_disconnectid )
{
    
ClrBits(g_IsAliveid);
    
ClrAimingPlayer(id);
}

public 
PlayerLifeid )
{
    if( 
is_user_alive(id) )
    {
        
SetBits(g_IsAliveid);
    }
    else
    {
        
ClrBits(g_IsAliveid);
        
ClrAimingPlayer(id);
    }
}

public 
TraceLine_PostFloat:start[3], Float:end[3], conditionsidtrace )
{
    if( 
IsPlayer(id) && GetBits(g_IsAliveid) )
    {
        new 
hit get_tr2(traceTR_pHit);
        if( 
IsPlayer(hit) )
            
SetAimingPlayer(idhit);
        else
            
ClrAimingPlayer(id);
    }
}

public 
AddToFullPack_Posteseenthostflagsplayerset )
{
    if( 
player && g_RenderTarget[host] == ent )
    {
        
set_es(esES_RenderFx     kRenderFxGlowShell);
        
set_es(esES_RenderColorg_PlayerColor[ent]);
    }
}

public 
EventHealthid )
{
    switch( 
read_data(1) )
    {
        case 
.. 24:
            
g_PlayerColor[id] = {25500};
        case 
25 .. 49:
            
g_PlayerColor[id] = {25518959};
        case 
50 .. 74:
            
g_PlayerColor[id] = {597212};
        default:
            
g_PlayerColor[id] = {5116887};
    }
}

SetAimingPlayeridplayer )
{
    
g_RenderTarget[id] = player;
    
    
SetBits(g_IsAimingPlayerid);
    
    if( !
g_fnAddToFullPack )
        
g_fnAddToFullPack register_forward(FM_AddToFullPack"AddToFullPack_Post"1);
}

ClrAimingPlayerid )
{
    
g_RenderTarget[id] = 0;
    
    
ClrBits(g_IsAimingPlayerid);
    
    if( !
g_IsAimingPlayer && g_fnAddToFullPack )
    {
        
unregister_forward(FM_AddToFullPackg_fnAddToFullPack1);
        
g_fnAddToFullPack 0;
    }

Don't know if this is better,.
__________________
youtube:
@holla16

Last edited by 11922911; 01-07-2014 at 00:50.
11922911 is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 01-07-2014 , 11:03   Re: hp based glow
Reply With Quote #2

Quote:
Originally Posted by 11922911 View Post
Just bored to have a quick try.
PHP Code:
#include amxmodx
#include fakemeta
#include hamsandwich

#define IsPlayer(%1) (1 <= %1 <= g_MaxClients)

#define GetBits(%1,%2) (%1 & (1 << (%2 & 31)))
#define SetBits(%1,%2) (%1 |= (1 << (%2 & 31)))
#define ClrBits(%1,%2) (%1 &= ~(1 << (%2 & 31)))

new g_IsAliveg_IsAimingPlayer;
new 
g_RenderTarget[33];
new 
g_PlayerColor[33][3];

new 
g_fnAddToFullPack;
new 
g_MaxClients;

public 
plugin_init()
{
    
register_event("Health""EventHealth""b");
    
    
register_forward(FM_TraceLine"TraceLine_Post"1);
    
    
RegisterHam(Ham_Spawn,  "player""PlayerLife"1);
    
RegisterHam(Ham_Killed"player""PlayerLife"1);
    
    
g_MaxClients get_maxplayers();
}

public 
client_disconnectid )
{
    
ClrBits(g_IsAliveid);
    
ClrAimingPlayer(id);
}

public 
PlayerLifeid )
{
    if( 
is_user_alive(id) )
    {
        
SetBits(g_IsAliveid);
    }
    else
    {
        
ClrBits(g_IsAliveid);
        
ClrAimingPlayer(id);
    }
}

public 
TraceLine_PostFloat:start[3], Float:end[3], conditionsidtrace )
{
    if( 
IsPlayer(id) && GetBits(g_IsAliveid) )
    {
        new 
hit get_tr2(traceTR_pHit);
        if( 
IsPlayer(hit) )
            
SetAimingPlayer(idhit);
        else
            
ClrAimingPlayer(id);
    }
}

public 
AddToFullPack_Posteseenthostflagsplayerset )
{
    if( 
player && g_RenderTarget[host] == ent )
    {
        
set_es(esES_RenderFx     kRenderFxGlowShell);
        
set_es(esES_RenderColorg_PlayerColor[ent]);
    }
}

public 
EventHealthid )
{
    switch( 
read_data(1) )
    {
        case 
.. 24:
            
g_PlayerColor[id] = {25500};
        case 
25 .. 49:
            
g_PlayerColor[id] = {25518959};
        case 
50 .. 74:
            
g_PlayerColor[id] = {597212};
        default:
            
g_PlayerColor[id] = {5116887};
    }
}

SetAimingPlayeridplayer )
{
    
g_RenderTarget[id] = player;
    
    
SetBits(g_IsAimingPlayerid);
    
    if( !
g_fnAddToFullPack )
        
g_fnAddToFullPack register_forward(FM_AddToFullPack"AddToFullPack_Post"1);
}

ClrAimingPlayerid )
{
    
g_RenderTarget[id] = 0;
    
    
ClrBits(g_IsAimingPlayerid);
    
    if( !
g_IsAimingPlayer && g_fnAddToFullPack )
    {
        
unregister_forward(FM_AddToFullPackg_fnAddToFullPack1);
        
g_fnAddToFullPack 0;
    }

Don't know if this is better,.
Its not.
You update glow color when player hp is changed what is bad because if player fall, you update glow color but it is useless for this case because you dont show glow for floor right?
You need to update glow color only when player take dmg to ohter player.

Also i dont think its useful to register and unregister that "FM_AddToFullPack" forward.
It wont be getting called if there is no players in the server.
.Dare Devil. is offline
ezio_auditore
Senior Member
Join Date: May 2013
Old 01-16-2014 , 05:28   Re: hp based glow
Reply With Quote #3

Quote:
Originally Posted by .Dare Devil. View Post
Its not.
You update glow color when player hp is changed what is bad because if player fall, you update glow color but it is useless for this case because you dont show glow for floor right?
You need to update glow color only when player take dmg to ohter player.

Also i dont think its useful to register and unregister that "FM_AddToFullPack" forward.
It wont be getting called if there is no players in the server.
I am not glowing the floor or something

It glows user according to his/her HP and that only when we aim
__________________
ezio_auditore is offline
Send a message via Skype™ to ezio_auditore
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 01-16-2014 , 07:24   Re: hp based glow
Reply With Quote #4

Quote:
Originally Posted by ezio_auditore View Post
I am not glowing the floor or something

It glows user according to his/her HP and that only when we aim
Or shoot right? Because when i tested your plugin, i had to shoot player to see glow.
My code is also working that way.
.Dare Devil. is offline
ezio_auditore
Senior Member
Join Date: May 2013
Old 01-17-2014 , 01:15   Re: hp based glow
Reply With Quote #5

Quote:
Originally Posted by .Dare Devil. View Post
Or shoot right? Because when i tested your plugin, i had to shoot player to see glow.
My code is also working that way.
not actually

It makes a player glow when you aim at him.

it just works fine
__________________
ezio_auditore is offline
Send a message via Skype™ to ezio_auditore
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 10:13.


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