Raised This Month: $ Target: $400
 0% 

change v_ model for a few seconds


Post New Thread Reply   
 
Thread Tools Display Modes
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 05-03-2024 , 18:11   Re: change v_ model for a few seconds
Reply With Quote #11

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>

const m_flNextPrimaryAttack 46

const USE_ANIMATION 0
new const model[] = "models/v_injectorX.mdl"
new const knife_model[] = "models/v_knife_r.mdl"

public plugin_init()
{
    
register_clcmd("say f""clcmd_f")
    
RegisterHam(Ham_Item_Deploy"weapon_knife""weapon_knife"1)
}

public 
plugin_precache()
{
    
precache_model(model)
    
precache_model(knife_model)
}

public 
clcmd_f(id)
{
    new 
weapon_model[64]
    
pev(idpev_viewmodel2weapon_modelcharsmax(weapon_model))
    
set_pev(idpev_viewmodel2model)
    
set_pev(idpev_frame0)
    
UTIL_SenwWeaponAnim(idUSE_ANIMATION)
    
set_pdata_float(fm_get_user_weapon_entity(idget_user_weapon(id)), m_flNextPrimaryAttack2.834)
    
set_task(2.83"end_animation"idweapon_modelsizeof(weapon_model))
}

public 
weapon_knife(knife_entity)
{
    new 
id pev(knife_entitypev_owner)
    if (
id)
    {
        if (
get_user_team(id) == 2)
            
set_pev(idpev_viewmodel2knife_model)
    }
}

public 
end_animation(weapon_model[64], id)
{
    if (
is_user_alive(id))
    {
        new 
weapon_entity fm_get_user_weapon_entity(idget_user_weapon(id))
        
ExecuteHam(Ham_Item_Deployweapon_entity)
        
set_pev(idpev_viewmodel2weapon_model)
    }
}

// https://forums.alliedmods.net/showpost.php?p=2387036&postcount=2
stock UTIL_SenwWeaponAnim(const pPlayer, const Sequence)
{
    
set_pev(pPlayerpev_weaponanimSequence)
    
    
message_begin(MSG_ONE_UNRELIABLESVC_WEAPONANIM, .player pPlayer)
    
write_byte(Sequence)
    
write_byte(pev(pPlayerpev_body))
    
message_end()

__________________
bigdaddy424 is offline
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 05-04-2024 , 08:55   Re: change v_ model for a few seconds
Reply With Quote #12

thank you very much, works just the way i wanted
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 05-05-2024 , 19:56   Re: change v_ model for a few seconds
Reply With Quote #13

ive had the same issue where animation would overlap and replay but im not sure whats causing it. tried commenting `UTIL_SenwWeaponAnim` but animation would start at random time and im afraid you have to leave it like that unless you could tweak it with rehlds or maybe this problem already has been covered on the forums then id suggest searching for a solution. you still have to account for weapon switches so id recommend looping all weapons using `item_deploy` and removing the task. you should to the same on `_disconnected`. good luck!
__________________
bigdaddy424 is offline
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 05-06-2024 , 12:35   Re: change v_ model for a few seconds
Reply With Quote #14

doesnt bother me at all that its played two times, i saw that sometimes it is on righthand and sometimes on lefthand too, but maybe thats just how the animation is, for now it works just the way i wanted, thank you so so much mate
__________________
a simple act of caring creates an endless ripple.
Nutu_ 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 14:36.


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