Raised This Month: $ Target: $400
 0% 

Get origin in player's viewcone?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 11-25-2019 , 19:01   Re: Get origin in player's viewcone?
Reply With Quote #5

Actually, I've been playing around my code a bit and tried different methods. The entity is there. I'm getting the logs I want. For example, in my testmap, the sprite entity has an id of 38, as seen in logs.

PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>

new TestSprite = -1;
new 
Float:fTestOrigin[3];

public 
plugin_precache()
{
    
register_forward(FM_Spawn"FwdSpawn");
}

public 
plugin_init()
{
    
register_plugin("Viewcone Test""1.0""ridavcrum");

    
RegisterHam(Ham_Think"player""HamPlayerThink");
}

public 
FwdSpawn(ent)
{
    
log_amx("ENTITY: %d, START"ent);
    
    if(!
pev_valid(ent))
    {
        
log_amx("ENTITY: %d, INVALID"ent);
        return 
FMRES_IGNORED;
    }
    
    
log_amx("ENTITY: %d, VALID"ent);
        
    new 
ClassName[32];
    
pev(entpev_classnameClassNamecharsmax(ClassName));
    
    
log_amx("ENTITY: %d, CLASSNAME: %s"entClassName);
    
    if(
equali(ClassName"env_sprite"))
    {
        new 
TargetName[32];
        
pev(entpev_targetnameTargetNamecharsmax(TargetName));
        
        
log_amx("ENTITY: %d, TARGETNAME: %s"entTargetName);
        
        if(
equali(TargetName"sprite_test"))
        {
            
TestSprite ent;
            
            
log_amx("ENTITY: %d, END !!"ent);
            return 
FMRES_HANDLED;
        }
    }
    
    
log_amx("ENTITY: %d, END"ent);
    return 
FMRES_IGNORED;
}

public 
HamPlayerThink(id)
{
    if(
is_in_viewcone(idfTestOrigin1) || is_visible(idTestSprite))
        
client_print(idprint_chat"%s%s"is_in_viewcone(idfTestOrigin1) ? "IN_VIEWCONE" ""is_visible(idSprite) ? " | IS_VISIBLE" "");

None return true. Bleh!

Yes, I can definitely see the entity. It's in the middle of the room, basically.

Last edited by redivcram; 11-25-2019 at 19:02.
redivcram is offline
 



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 02:57.


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