I went with body anyway, because I'll probably use completely different models too.
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include < fun >
#include < fakemeta >
#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Author"
const ANIM_DEPLOY = 3
new g_body
public plugin_init()
{
register_plugin( PLUGIN, VERSION, AUTHOR )
register_clcmd( "gettestnade", "gettestnade" )
register_clcmd( "changeskin", "changeskin" )
register_forward( FM_UpdateClientData, "UpdateClientData", 1 )
}
public UpdateClientData( id, sendweapons, cd )
{
if( sendweapons && get_user_weapon( id ) == CSW_HEGRENADE )
{
static iAnimPrevious
new iAnim = get_cd( cd, CD_WeaponAnim )
if( iAnimPrevious != iAnim )
{
if( iAnim == ANIM_DEPLOY )
{
set_pev( id, pev_viewmodel2, "models/traxxrp/v_combined.mdl" )
}
client_print( id, print_chat, "UpdateClientData iAnim: %d", iAnim )
flushanimation( id, iAnim, g_body )
iAnimPrevious = iAnim
}
}
}
public plugin_precache( )
{
precache_model( "models/traxxrp/v_combined.mdl" )
}
public gettestnade( id )
{
give_item( id, "weapon_hegrenade" )
}
public changeskin( id )
{
new szArgs[ 4 ]
read_args( szArgs, charsmax( szArgs ) )
remove_quotes( szArgs )
trim( szArgs )
g_body = str_to_num( szArgs )
flushanimation( id, ANIM_DEPLOY, g_body )
client_print( id, print_console, "Setting animation with pev_body: %d", g_body )
}
flushanimation( id, iAnim, iBodyValue )
{
set_pev( id, pev_weaponanim, iAnim )
message_begin( MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, id )
write_byte( iAnim )
write_byte( iBodyValue )
message_end( )
}
It works more or less, but for some reason, the deploy animation never gets the correct body value. I actually need to wait for the idle animation swap, then it gets properly changed. Also when another animation's played, the model flickers back to it's original body value for one frame, then it goes back to the correct one. Do you have any idea? I'm attaching the model as well in case you want to try it. The "other" body value is 3, so use changeskin 3.
The code is bad but it's enough for testing. Didn't feel like using Ham_Item_Deploy.
Edit: I think that the animation flicker is caused by the fact FM_UpdateClientData is a post forward, however it's impossible to replace the animation in a pre call.
Currently busy working on a very large scale anime database project.