Raised This Month: $32 Target: $400
 8% 

Change Weapon Sub-Model (v_)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 05-09-2016 , 15:59   Change Weapon Sub-Model (v_)
Reply With Quote #1

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.



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

Last edited by Syturi0; 05-09-2016 at 16:03.
Syturi0 is offline
Rirre
Veteran Member
Join Date: Nov 2006
Old 05-09-2016 , 18:17   Re: Change Weapon Sub-Model (v_)
Reply With Quote #2

Without the model attached we can only guess. Maybe it is a "skin" part. So try pev_skin

Last edited by Rirre; 05-09-2016 at 18:20.
Rirre is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 05-09-2016 , 18:45   Re: Change Weapon Sub-Model (v_)
Reply With Quote #3

Quote:
Originally Posted by Rirre View Post
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.
__________________
gabuch2 is offline
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 05-09-2016 , 18:51   Re: Change Weapon Sub-Model (v_)
Reply With Quote #4

Quote:
Originally Posted by Rirre View Post
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.
Syturi0 is offline
safetymoose
Senior Member
Join Date: Feb 2015
Old 05-09-2016 , 19:36   Re: Change Weapon Sub-Model (v_)
Reply With Quote #5

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.
safetymoose is offline
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 05-09-2016 , 19:41   Re: Change Weapon Sub-Model (v_)
Reply With Quote #6

Quote:
Originally Posted by safetymoose View Post
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.
Oh okey, thank you.
Syturi0 is offline
SpannerSpammer
Member
Join Date: Mar 2006
Old 05-10-2016 , 03:46   Re: Change Weapon Sub-Model (v_)
Reply With Quote #7

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;
}
__________________
[NeoTF|DEV]SpannerSpammer-[AoE]-
NeoTF Development Team.
http://steamcommunity.com/groups/neotf
SpannerSpammer is offline
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 05-10-2016 , 06:13   Re: Change Weapon Sub-Model (v_)
Reply With Quote #8

Quote:
Originally Posted by SpannerSpammer View Post
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.
Syturi0 is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Location: Siiiiiiiiuu
Old 05-10-2016 , 18:57   Re: Change Weapon Sub-Model (v_)
Reply With Quote #9

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
__________________
Jhob94 is offline
man_s_our
Senior Member
Join Date: Jul 2017
Location: aim_taliban
Old 04-13-2018 , 09:31   Re: Change Weapon Sub-Model (v_)
Reply With Quote #10

I've seen the solution in backweapons plugin.
you need to use pev_body (int) to change the submodel
__________________
man_s_our is offline
Reply


Thread Tools
Display Modes

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 10:30.


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