AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Change Weapon Sub-Model (v_) (https://forums.alliedmods.net/showthread.php?t=282544)

Syturi0 05-09-2016 15:59

Change Weapon Sub-Model (v_)
 
I have seen alot of threads about this topic but none of them had the solution.
I got a v_ model, it contains multiple sub-models inside.
I want to choose wich sub-model will be shown.


This is the code to set viewmodel:
PHP Code:

set_pev(idpev_viewmodel2"models/server/testwep.mdl"

It works correctly.


Now, how can i choose wich sub-model will be shown?
I know for body models i just need to do:
PHP Code:

set_pev(idpev_body, *Number of SubModel*) 


How can i do the same for weapon v_ models?
I saw this code somewhere else
PHP Code:

    set_pev(idpev_viewmodel2"models/server/testwep.mdl")

    new 
yo[32]
    
get_weaponname(CSW_KNIFEyosizeof yo 1)
    
    new 
weapon fm_find_ent_by_owner(-1yoid)
    
set_pev(weaponpev_body, *Number of SubModel*) 

But it doesnt work.

http://i.imgur.com/Zjerbuz.jpg

Can somebody tell me a way to achieve this?
Thank you.

Rirre 05-09-2016 18:17

Re: Change Weapon Sub-Model (v_)
 
Without the model attached we can only guess. Maybe it is a "skin" part. So try pev_skin

gabuch2 05-09-2016 18:45

Re: Change Weapon Sub-Model (v_)
 
Quote:

Originally Posted by Rirre (Post 2417964)
Without the model attached we can only guess. Maybe it is a "skin" part. So try pev_skin

Yes you do, it's cleary a submodel.

However, with models with many "submodel" groups I don't know if it'll work. Since I don't know which one is changing.

Syturi0 05-09-2016 18:51

Re: Change Weapon Sub-Model (v_)
 
Quote:

Originally Posted by Rirre (Post 2417964)
Without the model attached we can only guess. Maybe it is a "skin" part. So try pev_skin

I first tryed pev_skin before going for sub-models method, it also didnt work.

safetymoose 05-09-2016 19:36

Re: Change Weapon Sub-Model (v_)
 
You cant set it because of client prediction. v_ models are handled client-side, and no matter how many times you change the v_ submodel, it will always set it back to the first one. Submodels work fine on p_ and w_ models, but they dont work with v_ models.

Syturi0 05-09-2016 19:41

Re: Change Weapon Sub-Model (v_)
 
Quote:

Originally Posted by safetymoose (Post 2417980)
You cant set it because of client prediction. v_ models are handled client-side, and no matter how many times you change the v_ submodel, it will always set it back to the first one. Submodels work fine on p_ and w_ models, but they dont work with v_ models.

:cry: Oh okey, thank you.

SpannerSpammer 05-10-2016 03:46

Re: Change Weapon Sub-Model (v_)
 
I don't know if this will work, but try this:
Hook UpdateClientData, see if the viewmodel is the custom one one you set.
If it is, then set a task for about 0.5 seconds or more to send an SVC_WEAPONANIM MSG
to the client (You have to delay this for the Update MSG to be sent to the client first).
Set the weapon animation and bodygroup as needed.

Code:

stock SendWeaponAnim( id, iAnim, iBody )
{
    if ( !is_valid_player(id) || is_user_bot( id ) ) return 0; // check player validity first with some function (Humans only)
    set_pev( id, pev_weaponanim, iAnim );

    message_begin( MSG_ONE, SVC_WEAPONANIM, _, id );
    write_byte( iAnim );  // sequence number.
    write_byte( iBody );  // weaponmodel bodygroup.
    message_end();

    return 1;
}


Syturi0 05-10-2016 06:13

Re: Change Weapon Sub-Model (v_)
 
Quote:

Originally Posted by SpannerSpammer (Post 2418022)
I don't know if this will work, but try this:
Hook UpdateClientData, see if the viewmodel is the custom one one you set.
If it is, then set a task for about 0.5 seconds or more to send an SVC_WEAPONANIM MSG
to the client (You have to delay this for the Update MSG to be sent to the client first).
Set the weapon animation and bodygroup as needed.

Code:

stock SendWeaponAnim( id, iAnim, iBody )
{
    if ( !is_valid_player(id) || is_user_bot( id ) ) return 0; // check player validity first with some function (Humans only)
    set_pev( id, pev_weaponanim, iAnim );

    message_begin( MSG_ONE, SVC_WEAPONANIM, _, id );
    write_byte( iAnim );  // sequence number.
    write_byte( iBody );  // weaponmodel bodygroup.
    message_end();

    return 1;
}


First of all thank you for helping me!



Quote:

see if the viewmodel is the custom one one you set.
How can i check if the viewmodel is the one i set?



Quote:

to send an SVC_WEAPONANIM MSG
to the client
Like this?
PHP Code:

message_begin(MSG_ONESVC_WEAPONANIM, {000}, player)
write_byte(iAnim)
write_byte(iHands// id of hands
message_end() 


Quote:

Set the weapon animation and bodygroup as needed.
Where?


Btw user Backstabnoob said it will look bad... (https://forums.alliedmods.net/showpo...0&postcount=25)

I guess i should forget this and just make seperated model files.
Too much work and it will not look good.

Jhob94 05-10-2016 18:57

Re: Change Weapon Sub-Model (v_)
 
I know one way, but it's poor way, cpu expensive, and will not look 100% fine. Sometimes it will show the first body of list since it will be frame per frame

man_s_our 04-13-2018 09:31

Re: Change Weapon Sub-Model (v_)
 
I've seen the solution in backweapons plugin.
you need to use pev_body (int) to change the submodel


All times are GMT -4. The time now is 18:43.

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