AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [CSGO] Hide and Show player weapon world model (weapon on hands) (https://forums.alliedmods.net/showthread.php?t=302638)

Bacardi 11-05-2017 09:49

[CSGO] Hide and Show player weapon world model (weapon on hands)
 
Snip

Hide player weapon from hands.


PHP Code:

/*
 * Replace weapon weaponworldmodel-entity model with null model (csgo)
 *
*/
stock bool weaponworldmodel_hide(int weapon)
{
    
// Hide player weaponworldmodel with null model
    
int model PrecacheModel("models/props_doors/null.mdl");

    if(
model == 0)
    {
        
LogError("weaponworldmodel_hide(weapon) - error precache model 'models/props_doors/null.mdl'");
        return 
false//error
    
}


    
int weaponworldmodel GetEntPropEnt(weaponProp_Send"m_hWeaponWorldModel");

    if(
weaponworldmodel == -1)
    {
        return 
false;
    }

    
SetEntProp(weaponworldmodelProp_Send"m_nModelIndex"model);
    return 
true;
}


/*
 * Set weapon weaponworlmodel-entity model back with weapon worldmodel index
 *
*/
stock bool weaponworldmodel_show(int weapon)
{
    
// Show player weaponworldmodel model
    
int weaponworldmodel GetEntPropEnt(weaponProp_Send"m_hWeaponWorldModel");

    if(
weaponworldmodel == -1)
    {
        return 
false;
    }


    
int model GetEntProp(weaponProp_Send"m_iWorldModelIndex");

    if(
model <= 0)
    {
        
LogError("weaponworldmodel_show(weapon) - error invalid model index");
        return 
false//error
    
}

    
SetEntProp(weaponworldmodelProp_Send"m_nModelIndex"model);

    return 
true;






How to use quick
Code:

hide_all_players_weapon()
{
        int entity = -1;
        while( (entity = FindEntityByClassname(entity, "weapon_*")) != -1 )
        {
                weaponworldmodel_hide(entity);
        }
}


rodrigo286 11-12-2017 15:30

Re: [CSGO] Hide and Show player weapon world model (weapon on hands)
 
Thanks Barcardi, works perfectly.

Any way to hide viewmodel also?

I found some ways but any works correctly with customs arms model.

Thanks.

Ermert1992 11-12-2017 17:33

Re: [CSGO] Hide and Show player weapon world model (weapon on hands)
 
I've searched this and now i have it! Thank you!

Mitchell 11-12-2017 17:34

Re: [CSGO] Hide and Show player weapon world model (weapon on hands)
 
Quote:

Originally Posted by rodrigo286 (Post 2560071)
Thanks Barcardi, works perfectly.

Any way to hide viewmodel also?

I found some ways but any works correctly with customs arms model.

Thanks.

SetEntProp(client, Prop_Send, "m_bDrawViewmodel", false);

rodrigo286 11-12-2017 18:17

Re: [CSGO] Hide and Show player weapon world model (weapon on hands)
 
Quote:

Originally Posted by Mitchell (Post 2560101)
SetEntProp(client, Prop_Send, "m_bDrawViewmodel", false);

Thanks for help but this remove knife and custom zombie arms, i need remove only weapon model.

Screenshot:

https://i.imgur.com/TABSgUL.jpg

My code:

PHP Code:

    SDKHook(clientSDKHook_WeaponCanUseOnWeaponCanUse);
    
DisarmPlayer(client);
    
GivePlayerItem(client"weapon_knife");
    
int weaponIndex GetEntPropEnt(clientProp_Send"m_hMyWeapons"client);
    while((
weaponIndex FindEntityByClassname(weaponIndex"weapon_*")) != -){weaponworldmodel_hide(weaponIndex);}
    
SetEntProp(clientProp_Send"m_bDrawViewmodel"false); 

Thanks for all help.

rodrigo286 11-13-2017 10:47

Re: [CSGO] Hide and Show player weapon world model (weapon on hands)
 
To work with this snip:

https://forums.alliedmods.net/showpo...29&postcount=1

Arms also include animations, i try import animations from other old hand skin but dont work property.

Any way if no need arms with animation?

Thanks.

rodrigo286 11-13-2017 15:34

Re: [CSGO] Hide and Show player weapon world model (weapon on hands)
 
I edit stock ct knife model and made invisible version and get this. :)

It does not look very good, because the hand still holds the invisible knife.

I exists way to make hands open like left hand.

PHP Code:

public OnConfigsExecuted()
{
    
g_iSMGModel PrecacheModel("models/weapons/rodrigo286/v_inv_stock_knife/v_inv_stock_knife.mdl");


PHP Code:

public OnClientWeaponSwitchPost(clientwpnid)
{
    
decl String:szWpn[64];
    
GetEntityClassname(wpnid,szWpn,sizeof(szWpn));

    if(
StrEqual(szWpn"weapon_knife")){
        
SetEntProp(wpnidProp_Send"m_nModelIndex"0);
        
SetEntProp(clientProp_Send"m_nModelIndex"PrecacheModel("models/player/custom_player/kuristaja/walker/walkerv2.mdl"));
        
SetEntProp(g_PVMid[client], Prop_Send"m_nModelIndex"g_iSMGModel);
        
SetEntPropString(clientProp_Send"m_szArmsModel""models/player/custom_player/kuristaja/walker/walker_arms.mdl");
    }


https://i.imgur.com/N4kBz9E.jpg

Thanks.

Qes 03-02-2018 06:34

Re: [CSGO] Hide and Show player weapon world model (weapon on hands)
 
How I can hide world weapon on give player? (not all players)


All times are GMT -4. The time now is 15:53.

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