[AYUDA] Enseñar vida de entidad al dueño
#1
Hola a todos, bueno lo que quiero hacer es enseñar en un central print la vida de la entidad cuando es atacado pero solo enseñarselo al dueño, por ejemplo cuando un zombie ataca a una entidad digamos un saco de arena quiero que le enseñe un central print con el hp solo al dueño pero que solo salga el print cuando es atacado, como puedo hacerlo me darian un ejemplo, gracias antemano..
Responder
#2
Así, sin dejar code y nada es complicado.

Primero le tendrías que poner el takedamage de la entidad en true y darle un owner cuando la creas (con EV_INT_iuser1 por ejemplo), obviamente también hay que darle vida y ponerle un classname.

Ahora registras el takedamage con Ham, poniendo info_target. (en plugin_init)

Creas el public, chequeas que la entidad sea válida y el classname sea el que quieres.
Obtienes el owner que guardaste anteriormente, chequeas que esté conectado/vivo, obtienes la vida que le queda a la entidad y muestras el print.

es fácil, espero que no me haya faltado nada
(17/04/2015, 03:36 PM)Neeeeeeeeeel.- escribió: No se va a volver a conectar a internet en toda su puta vida... nadie sube porno a mi foro y vive para contarlo.
Responder
#3
EV_INT_iuser1 para que sirve esto? podria ser con pev_owner?
Responder
#4
Código PHP:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <hamsandwich>
#include <engine>
#include <zombieplague>

#define PLUGIN "TestEntity"
#define VERSION "1.0"
#define AUTHOR "LA BANDA"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
    
RegisterHam(Ham_TakeDamage"info_target""fw_TakeDamage_Pallet_Post"1)
}

public 
fw_TakeDamage_Pallet_Post(iVictimiInflictoriAttacker)
{
    static 
szClassName[32]
    
entity_get_string(iVictimEV_SZ_classnameszClassNamecharsmax(szClassName))
    
    if(
equal(szClassName"amx_pallet") && is_valid_ent(iVictim))
        if(
<= iAttacker <= 32 && is_user_alive(iAttacker) && zp_get_user_zombie(iAttacker))
            
client_print(iAttackerprint_center"Vida del saco: %d"floatround(entity_get_float(iVictimEV_FL_health)))


La verdad no lo probe pero adaptalo.
Responder
#5
(01/11/2013, 03:48 PM)wicho escribió: EV_INT_iuser1 para que sirve esto? podria ser con pev_owner?



si utilizas pev_owner el que pongas de owner lo atraviesa según testee yo hace tiempo.



EV_INT_iuser1 no sirve para nada, por si quieres almacenar algún dato de la entidad sin crear variables por ejemplo

@LA_BANDA le estás mostrando la vida al que ataca y creo que no se puede registrar el takedamage así, tiene que ser info_target
(17/04/2015, 03:36 PM)Neeeeeeeeeel.- escribió: No se va a volver a conectar a internet en toda su puta vida... nadie sube porno a mi foro y vive para contarlo.
Responder
#6
EV_INT_iuser* y pev_iuser* sirve para almacenar un número entero en la entidad seleccionada

Ni te molestes en enviarme un mensaje privado para pedirme ayuda porque NO lo voy a contestar.
Gracias por su atención.
Responder
#7
Ok gracias por la explicacion y Raulitop cuando vos decis que hay q darle un owner cuando se crea la entidad queres decir que lo tengo que hacer aqui place_palletwbags(id) (en el caso de la sandbags) que es el public donde se crea la entidad cierto?

Código PHP:
public place_palletwbags(id

     
    if( 
palletscout == get_pcvar_num(maxpallets) ) 
    { 
        
client_print(id,print_chat,"[ZP] For security reasons only allow %d Sandbags on the server!",get_pcvar_num 

(maxpallets)); 
        return 
PLUGIN_HANDLED
    } 
     
    
// create a new entity  
    
new ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"func_wall")); 
     
     
    
// set a name to the entity 
    
set_pev(ent,pev_classname,"amxx_pallets"); 

     
    
// set model         
    
engfunc(EngFunc_SetModel,ent,g_models[random(sizeof g_models)]); 
     
    
// register a new var. for origin 
    
static Float:xorigin[3]; 
    
get_user_hitpoint(id,xorigin); 
     
     
    
// check if user is aiming at the air  
    
if(engfunc(EngFunc_PointContents,xorigin) == CONTENTS_SKY
    { 
        
client_print(id,print_chat,"[ZP] You can not put sandbags in the sky!"); 
        return 
PLUGIN_HANDLED
    } 
     
     
    
// set sizes 
    
static Float:p_mins[3], Float:p_maxs[3]; 
    
p_mins PALLET_MINS
    
p_maxs PALLET_MAXS
    
engfunc(EngFunc_SetSizeentp_minsp_maxs); 
    
set_pev(entpev_minsp_mins); 
    
set_pev(entpev_maxsp_maxs ); 
    
set_pev(entpev_absminp_mins); 
    
set_pev(entpev_absmaxp_maxs ); 

     
    
// set the rock of origin where is user placed 
    
engfunc(EngFunc_SetOriginentxorigin); 
     
     
    
// make the rock solid 
    
set_pev(ent,pev_solid,SOLID_BBOX); // touch on edge, block 
     
    // set the movetype 
    
set_pev(ent,pev_movetype,MOVETYPE_FLY); // no gravity, but still collides with stuff 
     
    // now the damage stuff, to set to take it or no 
    // if you set the cvar "pallets_wbags_health" 0, you can't destroy a pallet with bags 
    // else, if you want to make it destroyable, just set the health > 0 and will be 
    // destroyable. 
    
new Float:p_cvar_health get_pcvar_float(phealth); 
    switch(
p_cvar_health
    { 
        case 
0.0 
        { 
            
set_pev(ent,pev_takedamage,DAMAGE_NO); 
        } 
         
        default : 
        { 
            
set_pev(ent,pev_health,p_cvar_health); 
            
set_pev(ent,pev_takedamage,DAMAGE_YES); 
        } 
    } 
     
             
    static 
Float:rvec[3]; 
    
pev(id,pev_v_angle,rvec); 
     
    
rvec[0] = 0.0
     
    
set_pev(ent,pev_angles,rvec); 
     
    
// drop entity to floor 
    
fm_drop_to_floor(ent); 
     
    
// num .. 
    
palletscout++; 
     
    
// confirm message 
    
client_print(idprint_chat"[ZP] You have placed a Sandbags, you have %i remaining"g_bolsas[id]) 
    
    return 
PLUGIN_HANDLED

Responder
#8
Exacto

Ni te molestes en enviarme un mensaje privado para pedirme ayuda porque NO lo voy a contestar.
Gracias por su atención.
Responder
#9
Asi estaria bien?

Código PHP:
public place_palletwbags(OwnerEnt

     
    if( 
palletscout == get_pcvar_num(maxpallets) ) 
    { 
        
client_print(OwnerEnt,print_chat,"[ZP] For security reasons only allow %d Sandbags on the server!",get_pcvar_num 

(maxpallets)); 
        return 
PLUGIN_HANDLED
    } 
     
    
// create a new entity  
    
new ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"func_wall")); 
     
     
    
// set a name to the entity 
    
set_pev(ent,pev_classname,"amxx_pallets"); 

    
    
entity_set_int(entEV_INT_iuser1OwnerEnt)

         
// set model         
    
engfunc(EngFunc_SetModel,ent,g_models[random(sizeof g_models)]); 
     
    
// register a new var. for origin 
    
static Float:xorigin[3]; 
    
get_user_hitpoint(OwnerEnt,xorigin); 
     
     
    
// check if user is aiming at the air  
    
if(engfunc(EngFunc_PointContents,xorigin) == CONTENTS_SKY
    { 
        
client_print(OwnerEnt,print_chat,"[ZP] You can not put sandbags in the sky!"); 
        return 
PLUGIN_HANDLED
    } 
     
     
    
// set sizes 
    
static Float:p_mins[3], Float:p_maxs[3]; 
    
p_mins PALLET_MINS
    
p_maxs PALLET_MAXS
    
engfunc(EngFunc_SetSizeentp_minsp_maxs); 
    
set_pev(entpev_minsp_mins); 
    
set_pev(entpev_maxsp_maxs ); 
    
set_pev(entpev_absminp_mins); 
    
set_pev(entpev_absmaxp_maxs ); 

     
    
// set the rock of origin where is user placed 
    
engfunc(EngFunc_SetOriginentxorigin); 
     
     
    
// make the rock solid 
    
set_pev(ent,pev_solid,SOLID_BBOX); // touch on edge, block 
     
    // set the movetype 
    
set_pev(ent,pev_movetype,MOVETYPE_FLY); // no gravity, but still collides with stuff 
     
    // now the damage stuff, to set to take it or no 
    // if you set the cvar "pallets_wbags_health" 0, you can't destroy a pallet with bags 
    // else, if you want to make it destroyable, just set the health > 0 and will be 
    // destroyable. 
    
new Float:p_cvar_health get_pcvar_float(phealth); 
    switch(
p_cvar_health
    { 
        case 
0.0 
        { 
            
set_pev(ent,pev_takedamage,DAMAGE_NO); 
        } 
         
        default : 
        { 
            
set_pev(ent,pev_health,p_cvar_health); 
            
set_pev(ent,pev_takedamage,DAMAGE_YES); 
        } 
    } 
     
             
    static 
Float:rvec[3]; 
    
pev(id,pev_v_angle,rvec); 
     
    
rvec[0] = 0.0
     
    
set_pev(ent,pev_angles,rvec); 
     
    
// drop entity to floor 
    
fm_drop_to_floor(ent); 
     
    
// num .. 
    
palletscout++; 
     
    
// confirm message 
    
client_print(OwnerEntprint_chat"[ZP] You have placed a Sandbags, you have %i remaining"g_bolsas[id]) 
    
    return 
PLUGIN_HANDLED


Código PHP:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <hamsandwich>
#include <engine>
#include <zombieplague>

#define PLUGIN "TestEntity"
#define VERSION "1.0"
#define AUTHOR "LA BANDA"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
    
RegisterHam(Ham_TakeDamage"info_target""fw_TakeDamage_Pallet_Post"1)
}

public 
fw_TakeDamage_Pallet_Post(iVictimiInflictoriAttacker)
{
    static 
szClassName[32], owner
    entity_get_string
(iVictimEV_SZ_classnameszClassNamecharsmax(szClassName))

owner entity_get_int(iVictimEV_INT_iuser1)
    
    if(
equal(szClassName"amxx_pallets") && is_valid_ent(iVictim))
        if(
<= iAttacker <= 32 && is_user_alive(owner) && zp_get_user_zombie(iAttacker))
            
client_print(ownerprint_center"Vida del saco: %d"floatround(entity_get_float(ownerEV_FL_health)))

Responder
#10
Probalo, debería funcionar

Ni te molestes en enviarme un mensaje privado para pedirme ayuda porque NO lo voy a contestar.
Gracias por su atención.
Responder
#11
No, no funciona..
Responder
#12
Por esto que tenes:
Código PHP:
// create a new entity  
    
new ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"func_wall")); 

Deberías cambiar lo siguiente:
Código PHP:
RegisterHam(Ham_TakeDamage"info_target""fw_TakeDamage_Pallet_Post"1
-->
Código PHP:
RegisterHam(Ham_TakeDamage"func_wall""fw_TakeDamage_Pallet_Post"1

PD: Acordate que la cvar de vida tiene que ser mayor a 0.0

Ni te molestes en enviarme un mensaje privado para pedirme ayuda porque NO lo voy a contestar.
Gracias por su atención.
Responder
#13
algo asi?



Código PHP:
#include <amxmodx>

#include <hamsandwich>

#include <engine>

#include <zombieplague>



#define PLUGIN "TestEntity"

#define VERSION "1.0"

#define AUTHOR "LA BANDA"





public plugin_init() 

{

    
register_plugin(PLUGINVERSIONAUTHOR)

    

    
RegisterHam(Ham_TakeDamage"func_wall""fw_TakeDamage_Pallet_Post"1)

}



public 
fw_TakeDamage_Pallet_Post(iVictimiInflictoriAttacker)

{

    static 
szClassName[32], ownerFloathealth 

    entity_get_string
(iVictimEV_SZ_classnameszClassNamecharsmax(szClassName))



    
owner entity_get_int(iVictimEV_INT_iuser1)

    
health entity_get_float(ownerEV_FL_health)

     

    

    if(
equal(szClassName"amxx_pallets") && is_valid_ent(iVictim))

        if(
<= iAttacker <= 32 && is_user_alive(owner) && zp_get_user_zombie(iAttacker))

      if (
health 0.0)

                 
health 0.0

            client_print
(ownerprint_center"Sand Bag: %d"floatround(health))


Responder
#14
Si, solo que no hace falta comprobar
Código PHP:
<= iAttacker <= 32 
si vas a comprobar que este vivo

Ni te molestes en enviarme un mensaje privado para pedirme ayuda porque NO lo voy a contestar.
Gracias por su atención.
Responder
#15
ok ahora sale el mensaje pero el problema es q siempre sale asi Sand Bag: 100 o sea cada vez que le pegan al costal sale siempre asi con el 100 eso es cuando sos humano y cuando sos zombie sale que tiene 2000 (la entidad todavia se queda cuando sos infectado), porque sale asi?
Responder
#16
Código PHP:
health entity_get_float

(owner EV_FL_health 

-->

Código PHP:
health entity_get_float

(iVictim EV_FL_health 

Ni te molestes en enviarme un mensaje privado para pedirme ayuda porque NO lo voy a contestar.
Gracias por su atención.
Responder
#17
Gracias alan funciona bien solo tengo otra pregunta como hago para pasar la vida a un porcentaje o sea que no salga la vida si no que lo represente como un porcentaje o sea que salga asi, sand bag: 100% y gracias otra vez por tu ayuda..
Responder
#18
Hacer una regla de tres simple

Maxima vida ---- 100%

Vida actual ------- x



Entonces:

Código:
Vida actual * 100 / maxima vida

Código PHP:
health 100 get_pcvar_float(p_cvar_health



Mas info:

http://es.wikipedia.org/wiki/Regla_de_tres

Ni te molestes en enviarme un mensaje privado para pedirme ayuda porque NO lo voy a contestar.
Gracias por su atención.
Responder
#19
si eso estaba haciendo ahorita, como sea gracias a todos por su ayuda..
Responder
#20
chequea que la entidad sea válida antes de obtener el classname
(17/04/2015, 03:36 PM)Neeeeeeeeeel.- escribió: No se va a volver a conectar a internet en toda su puta vida... nadie sube porno a mi foro y vive para contarlo.
Responder
#21
Yo deje el codigo hecho, nose que tanto problema.
Responder


Salto de foro:


Usuarios navegando en este tema: 1 invitado(s)