AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Bar health (https://forums.alliedmods.net/showthread.php?t=294894)

felipemilralze 03-10-2017 16:05

Bar health
 
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



Relaxing 03-11-2017 04:12

Re: Bar health
 
https://forums.alliedmods.net/showthread.php?t=293829

edon1337 03-11-2017 06:01

Re: Bar health
 
https://forums.alliedmods.net/showpo...04&postcount=3

felipemilralze 03-11-2017 16:59

Re: Bar health
 
Quote:

Originally Posted by edon1337 (Post 2502597)

I still do not understand AddToFullPack.

edon1337 03-12-2017 05:30

Re: Bar health
 
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.

Natsheh 03-12-2017 06:12

Re: Bar health
 
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]))
    } 


felipemilralze 03-14-2017 11:09

Re: Bar health
 
Quote:

Originally Posted by Natsheh (Post 2502935)
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)


All times are GMT -4. The time now is 18:00.

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