Raised This Month: $ Target: $400
 0% 

change v_ model for a few seconds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 04-27-2024 , 14:51   change v_ model for a few seconds
Reply With Quote #1

hi guys, lets say i would like to change a view model while buying smth from a shop menu, ex.
PHP Code:
case :
        {
            if (!
is_user_alive(id)) {
                
CromChat(id"!g[%s]!n You can't buy that item because you are dead."PREFIX);
                
client_cmd(id"spk ^"%s^""SoundMenu );
            }
            else
            {
                if ( 
points 10 ) {
                    
client_cmd id"spk ^"%s^""SoundMenu );
                    
CromChat (id"!g[%s]!n You dont have enough to buy !g100HP+100AP!n, you need !g10 points"PREFIX);
                    return 
PLUGIN_HANDLED;
                }
                new 
health get_user_health(id);
                if( 
health 300 ) {
                    
set_user_health (idget_user_health (id) + 100);
                    
set_user_armor(idget_user_armor(id) + 100);
                    
gKillerPointsid ] -= 10;
                    
client_cmd id"spk ^"%s^""MenuSound );
                    
set_hudmessage(255255255, -1.00.4501.05.00.10.21)
                    
show_hudmessage(id"You have purchased 100HP+100AP.");
                    
CromChat (0"!g[%s]!n Player!t %s !nhas purchased !g100HP+100AP !n[!g 10 points!n ]"PREFIXname);
                }
                else {
                    
client_cmd id"spk ^"%s^""SoundMenu );
                    
CromChat(id"!g[%s]!n You are not allowed to buy health over !g300."PREFIX);
                }
            }
        } 
and while buying the health i would like to add a specific animation v_.mdl and then to be back to normal, to the weapon or the pistol or the knife that the player had in head, is that possible?
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 04-27-2024 , 21:53   Re: change v_ model for a few seconds
Reply With Quote #2

can you give a real example
define whats a v_.mdl whether its a special animation on a weapon or a totally different viewmodel.
elaborate what weapon or the pistol or the knife that the player had in head means
__________________
bigdaddy424 is offline
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 04-28-2024 , 19:07   Re: change v_ model for a few seconds
Reply With Quote #3

i will attach the "animation" i'd like to add when the player buys health
lets say a player has an AK in had and he uses the shop menu to buy the health, the v_ak47 would stop showing and that v_animation to be shown, but also while the animation is showing, he shouldnt be able to shoot or smth

edit: cant attach .mdl file, ill send it via mediafire: https://www.mediafire.com/file/e8ihb...ctorX.mdl/file
__________________
a simple act of caring creates an endless ripple.

Last edited by Nutu_; 04-30-2024 at 17:48.
Nutu_ is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 04-28-2024 , 23:56   Re: change v_ model for a few seconds
Reply With Quote #4

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

#define m_iActiveItem 373
#define LINUX_DIFF_PLAYER 5

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

public plugin_init()
    
register_clcmd("say f""clcmd_f")

public 
plugin_precache()
    
precache_model(model)

public 
clcmd_f(id)
{
    new 
animation_entity engfunc(EngFunc_AllocStringmodel)
    
set_pev_string(idpev_viewmodel2animation_entity)
    
UTIL_SenwWeaponAnim(idUSE_ANIMATION)
    
set_task(2.83"end_animation"id)
}

public 
end_animation(id)
{
    if (
is_user_alive(id))
        
// https://amx-x.ru/viewtopic.php?f=8&t=28697
        
ExecuteHam(Ham_Item_Deployget_pdata_cbase(idm_iActiveItemLINUX_DIFF_PLAYER))
}

// 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 04-30-2024 , 11:39   Re: change v_ model for a few seconds
Reply With Quote #5

seems to work but i can shot while the animation is playing and also after the animation is done the weapons skins i got to the weapons or the knife, goes to default and you need to switch between them to get the skins back, could that be fixed? thanks indeed
__________________
a simple act of caring creates an endless ripple.

Last edited by Nutu_; 04-30-2024 at 17:49.
Nutu_ is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 05-02-2024 , 03:38   Re: change v_ model for a few seconds
Reply With Quote #6

You can get what you need with cs_weap_models_api.amxx.You can find examples in Yokomo's biohazard edit.I was using that way to change players weapon models,but now I forget how it works
__________________
Check my original plugins for cs 1.6 and subscribe on channel
Look at the video bellow to see zombie frost grenade

https://youtu.be/j0zspNfN-AM?si=_1IiGPETN-GQY9Ua

Look at the video below to see Zombie blind grenade

https://youtu.be/ORC7ZmoaipQ?si=QC8Bul96QGitUwX4
Krtola is offline
Send a message via Skype™ to Krtola
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 05-02-2024 , 21:30   Re: change v_ model for a few seconds
Reply With Quote #7

this works, just cancel task when switching weapons
only drawback is that you have to keep both weapon model replacement and syringe injector in the same source
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>

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)
    
UTIL_SenwWeaponAnim(idUSE_ANIMATION)
    
set_task(2.83"end_animation"idweapon_modelsizeof(weapon_model))
}

public 
weapon_knife(knife_entity)
{
    new 
id pev(knife_entitypev_owner)
    if (
id)
        
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()

to test select knife and press `f` in chat
__________________
bigdaddy424 is offline
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 05-03-2024 , 12:15   Re: change v_ model for a few seconds
Reply With Quote #8

the skins works but there's only one catch, if you could solve this too, i'd be glad
first, you can still shoot while the animation is played
second, i get the knife skin on t site (which are zombies) and i dont want it, could you make the knife model to be only for ct's? i tried do it myself but got some errors which i couldnt fix
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 05-03-2024 , 14:20   Re: change v_ model for a few seconds
Reply With Quote #9

you can shoot while animation is being played
PHP Code:
public weapon_knife(knife_entity)
{
    new 
id pev(knife_entitypev_owner)
    if (
id)
    {
        if (
get_user_team(id) == 2)
            
set_pev(idpev_viewmodel2knife_model)
    }

__________________
bigdaddy424 is offline
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 05-03-2024 , 16:31   Re: change v_ model for a few seconds
Reply With Quote #10

thats the thing, i dont want to be able to shoot with an m4a1 or any weapon while that animation is being played xd
__________________
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 10:14.


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