Raised This Month: $ Target: $400
 0% 

[L4D2] predicted_viewmodel can't set attach to other entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LinLinLin
Senior Member
Join Date: Sep 2021
Old 11-27-2023 , 00:37   [L4D2] predicted_viewmodel can't set attach to other entity
Reply With Quote #1

code below:
PHP Code:
int entity CreateEntityByName("predicted_viewmodel");
if( 
entity || !IsValidEntity(entity) )
    return ;
SetEntPropEnt(entityProp_Send"m_hOwner"client);
SetEntPropEnt(entityProp_Send"m_hWeapon"weapon);
SetEntityModel(entityRIOTSHIELD_V);
ActivateEntity(entity);
SetVariantString("!activator");
AcceptEntityInput(entity"SetParent"targetentity);
SetVariantString("!activator");
AcceptEntityInput(entity"SetAttached"targetentity);
DispatchSpawn(entity); 
by use cl_pdump to check entity, it still fix in (0.0.0) pos in the world and never follow the targetentity.
is the code got some mistake or just the predicted_viewmodel enttiy can't be attached to other entity?
LinLinLin is offline
101
Member
Join Date: Nov 2023
Old 11-27-2023 , 02:33   Re: [L4D2] predicted_viewmodel can't set attach to other entity
Reply With Quote #2

[ANY] WeaponModels - Change any weapon model .

have a look :
https://github.com/Andersso/SM-WeaponModels
Attached Files
File Type: zip SM-WeaponModels.zip (39.2 KB, 47 views)
101 is offline
LinLinLin
Senior Member
Join Date: Sep 2021
Old 11-27-2023 , 02:45   Re: [L4D2] predicted_viewmodel can't set attach to other entity
Reply With Quote #3

thanks, but i don't need to change the model of weapon.
i need another predicted_viewmodel to follow player view to do other job.
LinLinLin is offline
101
Member
Join Date: Nov 2023
Old 11-27-2023 , 02:57   Re: [L4D2] predicted_viewmodel can't set attach to other entity
Reply With Quote #4

Quote:
Originally Posted by LinLinLin View Post
thanks, but i don't need to change the model of weapon.
i need another predicted_viewmodel to follow player view to do other job.
Forget the weapons ,the code just shows how to setup <predicted_viewmodel> Entity correctly without missing any part , i thought that was ur problem ;)
101 is offline
LinLinLin
Senior Member
Join Date: Sep 2021
Old 11-27-2023 , 03:06   Re: [L4D2] predicted_viewmodel can't set attach to other entity
Reply With Quote #5

I create the entity successfully but it doesn't attach to the entity i want. So i am not sure the attach code is worked.
LinLinLin is offline
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
Earendil
Senior Member
Join Date: Jan 2020
Location: Spain
Old 12-07-2023 , 18:13   Re: [L4D2] predicted_viewmodel can't set attach to other entity
Reply With Quote #7

Quote:
Originally Posted by LinLinLin View Post
code below:
PHP Code:
int entity CreateEntityByName("predicted_viewmodel");
if( 
entity || !IsValidEntity(entity) )
    return ;
SetEntPropEnt(entityProp_Send"m_hOwner"client);
SetEntPropEnt(entityProp_Send"m_hWeapon"weapon);
SetEntityModel(entityRIOTSHIELD_V);
ActivateEntity(entity);
SetVariantString("!activator");
AcceptEntityInput(entity"SetParent"targetentity);
SetVariantString("!activator");
AcceptEntityInput(entity"SetAttached"targetentity);
DispatchSpawn(entity); 
by use cl_pdump to check entity, it still fix in (0.0.0) pos in the world and never follow the targetentity.
is the code got some mistake or just the predicted_viewmodel enttiy can't be attached to other entity?
You need to teleport your entity (use TeleportEntity), when parenting the entity will start moving from its origin relative to the player position and angles.
__________________
>>My plugins<<
>>GitHub<<
Earendil is offline
Reply



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 01:08.


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