AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   change v_ model for a few seconds (https://forums.alliedmods.net/showthread.php?t=347458)

Nutu_ 04-27-2024 14:51

change v_ model for a few seconds
 
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?

bigdaddy424 04-27-2024 21:53

Re: change v_ model for a few seconds
 
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

Nutu_ 04-28-2024 19:07

Re: change v_ model for a few seconds
 
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

bigdaddy424 04-28-2024 23:56

Re: change v_ model for a few seconds
 
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()



Nutu_ 04-30-2024 11:39

Re: change v_ model for a few seconds
 
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

Krtola 05-02-2024 03:38

Re: change v_ model for a few seconds
 
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

bigdaddy424 05-02-2024 21:30

Re: change v_ model for a few seconds
 
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

Nutu_ 05-03-2024 12:15

Re: change v_ model for a few seconds
 
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

bigdaddy424 05-03-2024 14:20

Re: change v_ model for a few seconds
 
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)
    }



Nutu_ 05-03-2024 16:31

Re: change v_ model for a few seconds
 
thats the thing, i dont want to be able to shoot with an m4a1 or any weapon while that animation is being played xd


All times are GMT -4. The time now is 02:27.

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