View Single Post
101
Member
Join Date: Nov 2023
Old 11-27-2023 , 23:59   Re: [L4D2] predicted_viewmodel can't set attach to other entity
Reply With Quote #6

the entity may not be attachable to another entity!
but i have noticed FollowEntity() in V-developer with predicted_viewmodel like :

PHP Code:
void CEntHost::CreateViewModelint index )
{
    
AssertIsPlayer() );
    
Assertindex >= && index MAX_VIEWMODELS );

    if ( !
IsPlayer() )
        return;

    if ( 
GetPlayer()->GetViewModelindex ) )
        return;

    
CPredictedViewModel *vm = (CPredictedViewModel *)CreateEntityByName"predicted_viewmodel" );

    if ( 
vm ) {
        
vm->SetAbsOriginGetAbsOrigin() );
        
vm->SetOwnerGetPlayer() );
        
vm->SetIndexindex );

        
DispatchSpawnvm );
        
vm->FollowEntityGetPlayer(), false ); //Your Problem Is Here 
        
vm->AddEffectsEF_NODRAW );

        
GetPlayer()->m_hViewModel.Setindexvm );
    }

So This may help :

Quote:
Re: Entity Parenting detection
Success Code for others:
Code:
new childEntity = GetEntPropEnt(targetEntity, Prop_Data, "m_hMoveChild");
new parentEntity = GetEntPropEnt(targetEntity, Prop_Data, "m_hMoveParent");
if -1 means no entity found
otherwise true
Quote:
Re: Actually you can check if you successfully attached entity for some attachment
PHP Code:
bool AttachEntityint entityint owner, const char[] attachment NULL_STRING )
{    
    
SetVariantString("!activator");
    
AcceptEntityInput(entity"SetParent"owner);
    
    if (!
IsNullString(attachment))
    {
        
SetVariantString(attachment);
        
AcceptEntityInput(entity"SetParentAttachMent"owner);
        
        if ( 
GetEntProp(entityProp_Data"m_iParentAttachment") == )
        {
            
LogError("Failed to set attachment");
            return 
false;
        }
    }
    return 
true;

101 is offline