Raised This Month: $51 Target: $400
 12% 

Bar health


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
felipemilralze
Senior Member
Join Date: Jul 2011
Location: Brazil
Old 03-10-2017 , 16:05   Bar health
Reply With Quote #1

Help me by this health bar just for nemesis, survivor, sniper, zombie plague 5.0.

Because I do not understand what this does "FM_AddToFullPack"

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <zp50_core>

#define PLUGIN "[ZP] Addon: Show Zombie Health"
#define VERSION "1.0"
#define AUTHOR "Dias : BlackCat (bug fix)"

new const healthbar_spr[] = "sprites/zb_healthbar.spr"
new g_playerbar[33] , g_isAlive[33]
new 
g_playerMaxHealth[33]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_Spawn"player""ham_spawn_post"1)
    
register_forward(FM_AddToFullPack"fm_addtofullpack_post"1)
    
    
register_event("ResetHUD""event_resethud""be")
    
register_event("DeathMsg""event_death""a")
    
register_event("Health""event_health""be")
    
    
make_healthbar()
}

public 
make_healthbar()
{
    static 
playerBarallocString
    allocString 
engfunc(EngFunc_AllocString"env_sprite")
    
    for( new 
id 1id <= get_maxplayers(); id ++ )
    {
        
g_playerbar[id] = engfunc(EngFunc_CreateNamedEntityallocString)
        
playerBar g_playerbar[id]
        
        if(
pev_valid(playerBar))
        {
            
set_pev(playerBarpev_scale0.25)
            
engfunc(EngFunc_SetModelplayerBarhealthbar_spr)
            
set_pev(playerBarpev_effectspev(playerBarpev_effects ) | EF_NODRAW)
        }
    }    
}

public 
plugin_precache() engfunc(EngFunc_PrecacheModelhealthbar_spr)

public 
ham_spawn_post(id)
{
    if(
is_user_alive(id))
    {
        
g_isAlive[id] = 1
    
}
}

public 
zp_fw_core_infect_post(id)
{
    
g_playerMaxHealth[id] = get_user_health(id)
}

public 
zp_fw_core_cure_post(id)
{
    
set_pev(g_playerbar[id], pev_effectspev(g_playerbar[id], pev_effects) | EF_NODRAW)
}

public 
client_disconnect(id
{
    
set_pev(g_playerbar[id], pev_effectspev(g_playerbar[id], pev_effects) | EF_NODRAW)
}

public 
event_resethud(id)
{
    
set_pev(g_playerbar[id], pev_effectspev(g_playerbar[id], pev_effects) | EF_NODRAW)
}

public 
event_death()
{
    new 
id read_data(2)
    
    
g_isAlive[id] = 0
    set_pev
(g_playerbar[id], pev_effectspev(g_playerbar[id], pev_effects) | EF_NODRAW)
}

public 
event_health(id)
{
    new 
hp get_user_health(id)
    
    if(
g_playerMaxHealth[id] < hp)
    {
        
g_playerMaxHealth[id] = hp
        set_pev
(g_playerbar[id], pev_frame99.0)
    }

    else
    {
        
set_pev(g_playerbar[id], pev_frame0.0 + (((hp 1) * 100) / g_playerMaxHealth[id]))
    }
}

public 
fm_addtofullpack_post(eseuserhosthost_flagsplayerp_set)
{
    if(!
player)
        return 
FMRES_IGNORED
        
    
if(!is_user_alive(host) || !is_user_alive(user))
        return 
FMRES_IGNORED
        
    
if(!zp_core_is_zombie(user))
        return 
FMRES_IGNORED
        
    
if(host == user)
        return 
FMRES_IGNORED
    
    
new Float:PlayerOrigin[3]
    
pev(userpev_originPlayerOrigin)
                            
    
PlayerOrigin[2] += 60.0
                        
    engfunc
(EngFunc_SetOriging_playerbar[user], PlayerOrigin)
    
set_pev(g_playerbar[user], pev_effectspev(g_playerbar[user], pev_effects) & ~EF_NODRAW)

    return 
FMRES_HANDLED


Last edited by felipemilralze; 03-10-2017 at 16:06.
felipemilralze is offline
Send a message via MSN to felipemilralze Send a message via Skype™ to felipemilralze
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 03-11-2017 , 06:01   Re: Bar health
Reply With Quote #3

https://forums.alliedmods.net/showpo...04&postcount=3
__________________
edon1337 is offline
felipemilralze
Senior Member
Join Date: Jul 2011
Location: Brazil
Old 03-11-2017 , 16:59   Re: Bar health
Reply With Quote #4

Quote:
Originally Posted by edon1337 View Post
I still do not understand AddToFullPack.
felipemilralze is offline
Send a message via MSN to felipemilralze Send a message via Skype™ to felipemilralze
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 03-12-2017 , 05:30   Re: Bar health
Reply With Quote #5

Quote:
AddToFullPack is a function when the game is rendering entities (players and non players) for a specific player. More that rendering, it sends all entities properties to that specific player so player can predict his own movements.
So basically it's helpful when dealing with Solidity of entities (SOLID_), Rendering of entities (set_rendering), Physics etc.
__________________

Last edited by edon1337; 03-12-2017 at 05:32.
edon1337 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-12-2017 , 06:12   Re: Bar health
Reply With Quote #6

PHP Code:

    
else if( g_playerMaxHealth[id] != 0)  // this check reduce crashing

    
{
        
set_pev(g_playerbar[id], pev_frame0.0 + (((hp 1) * 100) / g_playerMaxHealth[id]))
    } 
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
felipemilralze
Senior Member
Join Date: Jul 2011
Location: Brazil
Old 03-14-2017 , 11:09   Re: Bar health
Reply With Quote #7

Quote:
Originally Posted by Natsheh View Post
PHP Code:

    
else if( g_playerMaxHealth[id] != 0)  // this check reduce crashing

    
{
        
set_pev(g_playerbar[id], pev_frame0.0 + (((hp 1) * 100) / g_playerMaxHealth[id]))
    } 
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <zp50_core>
#include <zp50_class_assassin>
#include <zp50_class_assassin>

#define PLUGIN "[ZP] Addon: Show Zombie Health"
#define VERSION "1.0"
#define AUTHOR "Dias : BlackCat (bug fix)"

new const healthbar_spr[] = "sprites/zb_healthbar.spr"
new g_playerbar[33] , g_isAlive[33]
new 
g_playerMaxHealth[33]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_Spawn"player""ham_spawn_post"1)
    
register_forward(FM_AddToFullPack"fm_addtofullpack_post"1)
    
    
register_event("ResetHUD""event_resethud""be")
    
register_event("DeathMsg""event_death""a")
    
register_event("Health""event_health""be")
    
    
make_healthbar()
}

public 
make_healthbar()
{
    static 
playerBarallocString
    allocString 
engfunc(EngFunc_AllocString"env_sprite")
    
    for( new 
id 1id <= get_maxplayers(); id ++ )
    {
        
g_playerbar[id] = engfunc(EngFunc_CreateNamedEntityallocString)
        
playerBar g_playerbar[id]
        
        if(
pev_valid(playerBar))
        {
            
set_pev(playerBarpev_scale0.25)
            
engfunc(EngFunc_SetModelplayerBarhealthbar_spr)
            
set_pev(playerBarpev_effectspev(playerBarpev_effects ) | EF_NODRAW)
        }
    }    
}

public 
plugin_precache() engfunc(EngFunc_PrecacheModelhealthbar_spr)

public 
ham_spawn_post(id)
{
    if(
is_user_alive(id))
    {
        
g_isAlive[id] = 1
    
}
}

public 
zp_fw_core_infect_post(id)
{
    
g_playerMaxHealth[id] = get_user_health(id)
}

public 
zp_fw_core_cure_post(id)
{
    
set_pev(g_playerbar[id], pev_effectspev(g_playerbar[id], pev_effects) | EF_NODRAW)
}

public 
client_disconnect(id
{
    
set_pev(g_playerbar[id], pev_effectspev(g_playerbar[id], pev_effects) | EF_NODRAW)
}

public 
event_resethud(id)
{
    
set_pev(g_playerbar[id], pev_effectspev(g_playerbar[id], pev_effects) | EF_NODRAW)
}

public 
event_death()
{
    new 
id read_data(2)
    
    
g_isAlive[id] = 0
    set_pev
(g_playerbar[id], pev_effectspev(g_playerbar[id], pev_effects) | EF_NODRAW)
}

public 
event_health(id)
{
    new 
hp get_user_health(id)
    
    if(
g_playerMaxHealth[id] < hp)
    {
        
g_playerMaxHealth[id] = hp
        set_pev
(g_playerbar[id], pev_frame99.0)
    }

    else
    {
        
set_pev(g_playerbar[id], pev_frame0.0 + (((hp 1) * 100) / g_playerMaxHealth[id]))
    }
}

public 
fm_addtofullpack_post(eseuserhosthost_flagsplayerp_set)
{
    if(!
player)
        return 
FMRES_IGNORED
        
    
if(!is_user_alive(host) || !is_user_alive(user))
        return 
FMRES_IGNORED
        
    
if(!zp_class_assassin_get(user) || zp_class_nemesis_get(user)) // That does not work killer and nemesis is not with heath bar I do not understand addtopack
        
return FMRES_IGNORED
        
    
if(host == user)
        return 
FMRES_IGNORED
    
    
new Float:PlayerOrigin[3]
    
pev(userpev_originPlayerOrigin)
                            
    
PlayerOrigin[2] += 60.0
                        
    engfunc
(EngFunc_SetOriging_playerbar[user], PlayerOrigin)
    
set_pev(g_playerbar[user], pev_effectspev(g_playerbar[user], pev_effects) & ~EF_NODRAW)

    return 
FMRES_HANDLED

Can anyone make a simplified explanation what it would be:

(es, e, user, host, host_flags, player, p_set)
felipemilralze is offline
Send a message via MSN to felipemilralze Send a message via Skype™ to felipemilralze
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 01:17.


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