Saber si salio de una entidad
#1
Pregunta 
Hola a todos espero que estén bien.
Whatever

Tengo tiempo intentando de varias formas pero no lo logro hacer, quiero que cuando el humano entre al Aura Shield se le setee una variable a True y si sale se le setee a False
cuando lo hice me seteo el valor a true al entrar pero al salir tenia que colisionar con otra entidad para que me lo seteara a False, aqui les dejo la parte del code.
Código PHP:
new bool:non_infect[33] = false 

Código PHP:
public fw_Touch(enttoucher)
{
    
// Get entity classname
    
static classname[15]
    
entity_get_string(entEV_SZ_classnameclassnamecharsmax(classname))
    
    
// Prevent server crash if entity's private data not initalized
    
if (pev_valid(ent) != PDATA_SAFE) return FMRES_IGNORED;
    
    
// Valid user alive?
    
if (!is_user_valid_alive(toucher)) return FMRES_IGNORED;
    
    
    
// Check entity type
    
if (equal(classname"weaponbox"))
    {
        
// Don't pickup weapons if zombie, survivor or wesker (+PODBot MM fix)
        
if (g_class[toucher] >= ZOMBIE || ((g_class[toucher] == SURVIVOR || g_class[toucher] == WESKER) && !g_isbot[toucher]))
            return 
FMRES_SUPERCEDE;
        
        
// Don't check weapon level
        
if (get_pcvar_num(cvar_randweapons) || get_user_flags(toucher) & g_access_flag[ACCESS_WEAPONS_FREE])
            return 
FMRES_IGNORED;
        
        
// Get weapon's id and name
        
static weaponidwname[32], wname2[32]
        
weaponid cs_get_weaponbox_id(ent)
        if (
weaponidget_weaponname(weaponidwnamecharsmax(wname))
        else return 
FMRES_IGNORED;
    
        
// Primary or secondary weapon
        
if ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)
        {
            for (new 
0WPN_MAXIDSi++)
            {
                
ArrayGetString(g_primary_itemsiwname2charsmax(wname))
                if (
equal(wnamewname2))
                {
                    
// Don't pickup weapons if don't have the required level
                    
if (g_level[toucher] == ArrayGetCell(g_primary_levelsi))
                        return 
FMRES_SUPERCEDE;
                    else
                        return 
FMRES_IGNORED;
                }
            }
        }
        else if ((
1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)
        {
            for (new 
0ArraySize(g_secondary_items); i++)
            {
                
ArrayGetString(g_secondary_itemsiwname2charsmax(wname))
                if (
equal(wnamewname2))
                {
                    
// Don't pickup weapons if don't have the required level
                    
if (g_level[toucher] == ArrayGetCell(g_secondary_levelsi))
                        return 
FMRES_SUPERCEDE;
                    else
                        return 
FMRES_IGNORED;
                }
            }
        }
    }
    else if (
equal(classname"armoury_entity") || equal(classname"weapon_shield"))
    {
        
// Never pickup
        
return FMRES_SUPERCEDE;
    }
    else if (
equal(classname"forze_camp"))
    {
        
// Human/Nemesis/Alien/Zombie madness don't affect
        
if (g_class[toucher] < ZOMBIE || g_class[toucher] >= NEMESIS
            return 
FMRES_IGNORED;
        
        
// Get entity and toucher origin
        
static Float:ent_origin[3], Float:tou_origin[3]
        
pev(entpev_originent_origin)
        
pev(toucherpev_origintou_origin)
        
        for (new 
03i++)
        {
            
tou_origin[i] -= ent_origin[i]
            
tou_origin[i] *= 6.0
        
}
        
        
// Can't go into aurashield
        
set_pev(toucherpev_velocitytou_origin)
        
        
// Get aurashield damage cvar
        
static damagedamage get_pcvar_num(cvar_aurashielddamage)
        
        
// Instantly remove/Aura Shield received damage
        
if (g_aurashield_health[ent] - damage <= 0){
            
            
remove_aurashield_chest(ent1)
        }else{
            
g_aurashield_health[ent] -= damage
            set_hudmessage
(2552550, -1.0, -1.006.012.0)
            
show_hudmessage(toucher"Vida del aura: %d",g_aurashield_health[ent])
        }        
    }
    else if (
equal(classname"chest"))
    {
        
// Instantly remove
        
remove_aurashield_chest(ent0)
        
        
// Give point random
        
new randompointpoints
        randompoint 
random_num(01)
        
points random_num(06)
    
        
g_points[toucher][randompoint] += points
        zp_colored_print
(toucher"^x04[ZA]^x01 Has recogido un cofre, obtienes ^x04%d Punto%s %s^x01!"pointspoints "s" ""randompoint == "Humano" "Zombie")
    }
    return 
FMRES_IGNORED;


y asi fue mi ultimo intento de hacer que funcionara como quiero

Código PHP:
public fw_Touch(enttoucher)
{
    
// Get entity classname
    
static classname[15]
    
entity_get_string(entEV_SZ_classnameclassnamecharsmax(classname))
    
    if (
non_infect[toucher] && !pev_valid(ent) && !equal(classname"forze_camp"))
    {
        
non_infect[toucher] = false
        zp_colored_print
(toucher"^x04[non_ifect][false]")
    }
    
// Prevent server crash if entity's private data not initalized
    
if (pev_valid(ent) != PDATA_SAFE) return FMRES_IGNORED;
    
    
// Valid user alive?
    
if (!is_user_valid_alive(toucher)) return FMRES_IGNORED;
    
    
    
// Check entity type
    
if (equal(classname"weaponbox"))
    {
        
// Don't pickup weapons if zombie, survivor or wesker (+PODBot MM fix)
        
if (g_class[toucher] >= ZOMBIE || ((g_class[toucher] == SURVIVOR || g_class[toucher] == WESKER) && !g_isbot[toucher]))
            return 
FMRES_SUPERCEDE;
        
        
// Don't check weapon level
        
if (get_pcvar_num(cvar_randweapons) || get_user_flags(toucher) & g_access_flag[ACCESS_WEAPONS_FREE])
            return 
FMRES_IGNORED;
        
        
// Get weapon's id and name
        
static weaponidwname[32], wname2[32]
        
weaponid cs_get_weaponbox_id(ent)
        if (
weaponidget_weaponname(weaponidwnamecharsmax(wname))
        else return 
FMRES_IGNORED;
    
        
// Primary or secondary weapon
        
if ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)
        {
            for (new 
0WPN_MAXIDSi++)
            {
                
ArrayGetString(g_primary_itemsiwname2charsmax(wname))
                if (
equal(wnamewname2))
                {
                    
// Don't pickup weapons if don't have the required level
                    
if (g_level[toucher] == ArrayGetCell(g_primary_levelsi))
                        return 
FMRES_SUPERCEDE;
                    else
                        return 
FMRES_IGNORED;
                }
            }
        }
        else if ((
1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)
        {
            for (new 
0ArraySize(g_secondary_items); i++)
            {
                
ArrayGetString(g_secondary_itemsiwname2charsmax(wname))
                if (
equal(wnamewname2))
                {
                    
// Don't pickup weapons if don't have the required level
                    
if (g_level[toucher] == ArrayGetCell(g_secondary_levelsi))
                        return 
FMRES_SUPERCEDE;
                    else
                        return 
FMRES_IGNORED;
                }
            }
        }
    }
    else if (
equal(classname"armoury_entity") || equal(classname"weapon_shield"))
    {
        
// Never pickup
        
return FMRES_SUPERCEDE;
    }
    else if (
equal(classname"forze_camp"))
    {
        
// Human/Nemesis/Alien/Zombie madness don't affect
        
if (g_class[toucher] < ZOMBIE || g_class[toucher] >= NEMESIS){
            if(!
non_infect[toucher])
            {
                
non_infect[toucher] = true
                zp_colored_print
(toucher"^x04[non_ifect][true]")
                
            }
            return 
FMRES_IGNORED;
        }
        
// Get entity and toucher origin
        
static Float:ent_origin[3], Float:tou_origin[3]
        
pev(entpev_originent_origin)
        
pev(toucherpev_origintou_origin)
        
        for (new 
03i++)
        {
            
tou_origin[i] -= ent_origin[i]
            
tou_origin[i] *= 6.0
        
}
        
        
// Can't go into aurashield
        
set_pev(toucherpev_velocitytou_origin)
        
        
// Get aurashield damage cvar
        
static damagedamage get_pcvar_num(cvar_aurashielddamage)
        
        
// Instantly remove/Aura Shield received damage
        
if (g_aurashield_health[ent] - damage <= 0){
            
            
remove_aurashield_chest(ent1)
        }else{
            
g_aurashield_health[ent] -= damage
            set_hudmessage
(2552550, -1.0, -1.006.012.0)
            
show_hudmessage(toucher"Vida del aura: %d",g_aurashield_health[ent])
        }        
    }
    else if (
equal(classname"chest"))
    {
        
// Instantly remove
        
remove_aurashield_chest(ent0)
        
        
// Give point random
        
new randompointpoints
        randompoint 
random_num(01)
        
points random_num(06)
    
        
g_points[toucher][randompoint] += points
        zp_colored_print
(toucher"^x04[ZA]^x01 Has recogido un cofre, obtienes ^x04%d Punto%s %s^x01!"pointspoints "s" ""randompoint == "Humano" "Zombie")
    }
    return 
FMRES_IGNORED;


Les agradeceré mucho su ayuda.
Responder
#2
También puedes crear un think a la entidad y verificar si hay jugadores a X radio del centro de la entidad:

Puedes guiarte con esto:
https://forums.alliedmods.net/showpost.p...ostcount=5
[Imagen: b_350_20_323957_202743_f19a15_111111.png]

Estudia siempre; el tiempo es oro, lo material se puede recuperar pero el tiempo no se puede recuperar.
(02/10/2016, 05:05 PM)meTaLiCroSS escribió: Siempre me gusta ayudar cuando alguien esta interesado realmente en ver que esta programando.
(08/08/2019, 05:32 PM)meTaLiCroSS escribió: grax x el dato cr4ck


Mis aportes

PLUGINS
MAPAS
Menú LANG [SF] Sistema de Frags
Say System (Admin Prefix)
Responder
#3
no entiendo la verdad.

¿Algo asi?
Código PHP:
register_forward(FM_PlayerPreThink"fw_PlayerPreThink"

Código PHP:
public fw_PlayerPreThink(id)
{
    
// Not alive
    
if (!g_isalive[id]) return;
    
    
/*======================================
                 Reciente
    =======================================*/
    
new players[32], playernum find_sphere_class(id"player"240.0playerssizeof(players)); 
    
    for(--
numnum>=0num--) 
    { 
        
player players[num]; 

        if( 
player != id 
        { 
            
non_infect[id] = false
        

    } 
    
    
// Enable custom buyzone for player during buytime, unless zombie or survivor or time expired
    
if (g_cached_buytime 0.0 && g_class[id] < SURVIVOR && (get_gametime() < g_buytime[id] + g_cached_buytime) && pev_valid(g_buyzone_ent))
        
dllfunc(DLLFunc_Touchg_buyzone_entid)


    
// Silent footsteps for zombies?
    
if (g_cached_zombiesilent && (g_class[id] >= ZOMBIE && g_class[id] < NEMESIS))
        
set_pev(idpev_flTimeStepSoundSTEPTIME_SILENT)
    
    
// Player frozen?
    
if (g_frozen[id])
    {
        
set_pev(idpev_velocityFloat:{0.0,0.0,0.0}) // stop motion
        
return; // shouldn't leap while frozen
    
}
    
    
// --- Check if player should leap ---
    
    // Don't allow leap during freezetime
    
if (g_freezetime) return;
    
    
// Not zombie
    
if (g_class[id] < ZOMBIE) return;
    
    
// Check if proper CVARs are enabled and retrieve leap settings
    
static Float:cooldownFloat:current_time
    
if (g_class[id] == NEMESIS)
    {
        if (!
g_cached_leapnemesis) return;
        
cooldown g_cached_leapnemesiscooldown
    
}
    else if (
g_class[id] == ALIEN)
    {
        if (!
g_cached_leapalien) return;
        
cooldown g_cached_leapaliencooldown
    
}
    else
    {
        switch (
g_cached_leapzombies)
        {
            case 
0: return;
            case 
2: if (g_class[id] != FIRST_ZOMBIE) return;
            case 
3: if (g_class[id] != LAST_ZOMBIE) return;
        }
        
cooldown g_cached_leapzombiescooldown
    
}
    
current_time get_gametime()
    
    
// Cooldown not over yet
    
if (current_time g_lastleaptime[id] < cooldown) return;
    
    
// Not doing a longjump (don't perform check for bots, they leap automatically)
    
if (!g_isbot[id] && !(pev(idpev_button) & (IN_JUMP IN_DUCK) == (IN_JUMP IN_DUCK)))
        return;
    
    
// Not on ground or not enough speed
    
if (!(pev(idpev_flags) & FL_ONGROUND) || get_speed(id) < 0)
        return;
    
    static 
Float:velocity[3]
    
    
// Make velocity vector
    
velocity_by_aim(idg_class[id] == NEMESIS get_pcvar_num(cvar_leapnemesisforce) : g_class[id] == ALIEN get_pcvar_num(cvar_leapalienforce) : get_pcvar_num(cvar_leapzombiesforce), velocity)
    
    
// Set custom height
    
velocity[2] = g_class[id] == NEMESIS get_pcvar_float(cvar_leapnemesisheight) : g_class[id] == ALIEN get_pcvar_float(cvar_leapalienheight) : get_pcvar_float(cvar_leapzombiesheight)
    
    
// Apply the new velocity
    
set_pev(idpev_velocityvelocity)
    
    
// Update last leap time
    
g_lastleaptime[id] = current_time
    

Responder
#4
Nada, intente poner que ese code buscara todas las entidades de force camp cerca del jugador pero no me funciono, no hay otra forma.
Responder
#5
https://amxmodx-es.com/Thread-Entity-Render-Tool-1-0

En la entidad Force Camp le creas un think, y en ese think obtene todas las entidades guiandote con este plugin, y con un calculo matematico(distancia entre dos posiciones o puntos) verifica si esta a X distancia (osea radio), y si se encuentra o no ahi tenes la variable.

xD

Aca tenes mas info para guiarte con temas de entidades: (como colocarle el think etc)

https://amxmodx-es.com/Thread-Roach-AI-C...s-cochinas
Responder
#6
al crear el think me toca poner que detecte a los jugadores que entran en su radio verdad? algo asi
Código PHP:
public plugin_init()

        
register_think("forze_camp""aura_shield_think")
        ............
        ..................
}

public 
aura_shield_think(entity)
{
    if(!
is_valid_ent(entity))
        return;

    new 
players[32], playernum find_sphere_class(id"player"240.0playerssizeof(players)); 
        for(--
numnum>=0num--) 
        { 
            
player players[num]; 
            if( 
player != id )
            {
                
variable[id] = true
            
}

si esto logra funcionar, como puedo hacer para cuando este fuera de ese radio se ponga la vairable en false?, ese code fue el que dejo totopizza.
Responder
#7
(18/02/2019, 10:32 PM)luxor xD escribió: al crear el think me toca poner que detecte a los jugadores que entran en su radio verdad? algo asi
Código PHP:
public plugin_init()

        
register_think("forze_camp""aura_shield_think")
        ............
        ..................
}

public 
aura_shield_think(entity)
{
    if(!
is_valid_ent(entity))
        return;


    new 
players
        
new Float:pOrigin[3]
        new 
Float:eOrigin[3]
        for(
players 1players>=get_maxplayers(); players++) 
        { 
            
get_user_originplayersOrigin);
                        
entity_get_vectorENTIDADFORZECAMPEV_VEC_OrigineOrigin )

if( 
vector_distancepOrigineOrigin ) < rango... )
{
variable true :// si esta dentro del rango ...
}
else
{
variable false // si esta fuera del rango ...
}

si esto logra funcionar, como puedo hacer para cuando este fuera de ese radio se ponga la vairable en false?, ese code fue el que dejo totopizza.

tengo un teclado de mierda asi que ahi maso menos te deje el código armado, si con eso no lo armas, entonces que se yo, mas armadito imposible, solo te falta obtener las entidades entidadforzecamp, que no se si es la de entity que aparece, proba, fijate............
Responder
#8
Que malo soy para esto, no encuentro la entidad, la entidad no la veo creada fuera de los public al principio de hecho veo que llaman a la entidad asi,
Código PHP:
static entent find_ent_by_owner(-1"forze_camp"id
probe con esto
Código PHP:
g_aurashield_grenade[ent
que le dan el valor en este code
Código PHP:
aurashield_explode(entityowner)
{
    
// Get origin
    
static Float:originF[3]
    
pev(entitypev_originoriginF)
    
    
// Make the explosion
    
create_blast4(originF)
    
    
// Owner killed or infected?
    
if (!is_user_valid_alive(owner) || g_class[owner] >= ZOMBIE)
    {
        
// Get rid of the grenade
        
engfunc(EngFunc_RemoveEntityentity)
        return;
    }
    
    
// Collisions
    
static victim
    victim 
= -1
    
    
while ((victim engfunc(EngFunc_FindEntityInSpherevictimoriginFNADE_EXPLOSION_RADIUS)) != 0)
    {    
        
// Only effect alive non-spawnprotected zombies
        
if (!is_user_valid_alive(victim) || (g_class[victim] < ZOMBIE || g_class[victim] >= NEMESIS))
            continue;
        
        
// Get victim origin
        
static Float:vic_origin[3]
        
pev(victimpev_originvic_origin)
        
        for (new 
03i++)
        {
            
vic_origin[i] -= originF[i]
            
vic_origin[i] *= 10.0 // don't change!!
        
}
        
        
// Can't stay into aurashield
        
set_pev(victimpev_velocityvic_origin)
    }
    
    
// Create entity
    
new ent create_entity("info_target")
    
    
// Set aurashield's owner and grenade entity
    
set_pev(entpev_ownerowner)
    
g_aurashield_grenade[ent] = entity
    
    
// Set origin
    
entity_set_vector(entEV_VEC_originoriginF)
    
    
// Set entity classname and model
    
entity_set_string(entEV_SZ_classname"forze_camp")
    
entity_set_model(entmodel_aura_forzecamp)
    
    
// Set entity health
    
g_aurashield_health[ent] = get_pcvar_num(cvar_aurashieldhealth)
    
    
// Set entity solid
    
entity_set_int(entEV_INT_solidSOLID_TRIGGER)
    
    
// Set entity size
    
static Float:mins[3] = {-90.0, -90.0, -90.0}
    static 
Float:maxs[3] = {90.090.090.0}
    
entity_set_size(entminsmaxs)
    
    
// Random glow color
    
static GlowColor[3]
    for (new 
03i++) GlowColor[i] = random_num(0255)
    
    
// Give it a glow
    
set_rendering(entkRenderFxGlowShellGlowColor[0], GlowColor[1], GlowColor[2], kRenderTransAlpha16)


y tambien con esto

Código PHP:
const NADE_TYPE_AURASHIELD 4444

public aura_shield_think(entity)
{

}
entity_get_vector(  NADE_TYPE_AURASHIELDEV_VEC_origineOrigin 

tu code esta bien lo use con otro plugin diferente y me funciono, creo que mi problema esta aqui

Código PHP:
register_think("forze_camp""aura_shield_think"
Responder
#9
tenes que poner el think dentro de donde se crea la entidad, sino seria como si nada xD.

Antes del set_rendering pegaselo ahi pacman

new ent = create_entity("info_target")

estos guardalos en una variable con array osea [] y juntalos, despues le haces un loop con todas las auras y lesto, comparas distancias como te di el codigo y ya estaria creo.

y cuando se destruye o termina el aura deleteas ese que se borro pacman haces un loop y pones if ent == entremoved osea si tiene el mismo numerito pacman ya me entendes xD
Responder
#10
Cuantas auras por usuario se pueden crear?
[Imagen: b_350_20_323957_202743_f19a15_111111.png]

Estudia siempre; el tiempo es oro, lo material se puede recuperar pero el tiempo no se puede recuperar.
(02/10/2016, 05:05 PM)meTaLiCroSS escribió: Siempre me gusta ayudar cuando alguien esta interesado realmente en ver que esta programando.
(08/08/2019, 05:32 PM)meTaLiCroSS escribió: grax x el dato cr4ck


Mis aportes

PLUGINS
MAPAS
Menú LANG [SF] Sistema de Frags
Say System (Admin Prefix)
Responder
#11
No tiene limite, pero se lo limitare a 2 para que no aya lag
Responder


Salto de foro:


Usuarios navegando en este tema: 1 invitado(s)