Raised This Month: $32 Target: $400
 8% 

[CS:GO] Custom Viewmodel


Post New Thread Reply   
 
Thread Tools Display Modes
gubka
Veteran Member
Join Date: Jan 2012
Location: Russia
Old 11-04-2015 , 17:33   Re: [CS:GO] Custom Viewmodel
Reply With Quote #11

Zombie claws ported from cso2, I make same amount of anims in CS go order
__________________
gubka is offline
Send a message via ICQ to gubka
gubka
Veteran Member
Join Date: Jan 2012
Location: Russia
Old 11-04-2015 , 17:34   Re: [CS:GO] Custom Viewmodel
Reply With Quote #12

Tommrow I will update my zombie mod , where I optimized my method which changing view model , you can use any custom , and model don't flicks with ping 100
__________________
gubka is offline
Send a message via ICQ to gubka
gubka
Veteran Member
Join Date: Jan 2012
Location: Russia
Old 11-04-2015 , 17:37   Re: [CS:GO] Custom Viewmodel
Reply With Quote #13

Custom model don't flicks if player have next attack offset 0.0
__________________
gubka is offline
Send a message via ICQ to gubka
CareFully
Junior Member
Join Date: Oct 2015
Old 11-06-2015 , 09:37   Re: [CS:GO] Custom Viewmodel
Reply With Quote #14

Ok. I updated the code. It now changes the weapon model (not the viewmodel), to a model that has no animations. It seems to work now with all custom and offical models. Please test it now.

What i added:
PHP Code:
new g_iWorldModel;
public 
OnConfigsExecuted()
    
g_iWorldModel PrecacheModel("models/sticker_preview.mdl"); // Don't change

public OnClientWeaponSwitchPost(clientwpnid)
    
// SetEntProp(wpnid, Prop_Send, "m_nModelIndex", g_iSMGModel);
    // Changed to:
    
SetEntProp(wpnidProp_Send"m_nModelIndex"g_iWorldModel); 
Full code in op.
CareFully is offline
lingzhidiyu
Senior Member
Join Date: Mar 2014
Old 11-06-2015 , 10:41   Re: [CS:GO] Custom Viewmodel
Reply With Quote #15

Can you change world_droped model?
lingzhidiyu is offline
CareFully
Junior Member
Join Date: Oct 2015
Old 11-06-2015 , 11:36   Re: [CS:GO] Custom Viewmodel
Reply With Quote #16

PHP Code:
SetEntPropString(wpnidProp_Data"m_ModelName""modelname.mdl"); 
Setting this on weapon spawn (and when the weapon is dropped) will work. But it doesn't work on equipped weapons. I haven't found yet how to get worldmodels to work.
CareFully is offline
gubka
Veteran Member
Join Date: Jan 2012
Location: Russia
Old 11-06-2015 , 14:45   Re: [CS:GO] Custom Viewmodel
Reply With Quote #17

Code:
public void ThinkOnThinkPost(int iPlayer)
{
	// Check that player alive and exist
	if(!IsPlayerExist(iPlayer))
	{
		return;
	}
	
	// If zombie
	if(gZombie[iPlayer])
	{
		// Check current button
		int iButton = GetClientButtons(iPlayer);

		// Prevent from flipping on CS:GO
		if(iButton & IN_ATTACK || iButton & IN_ATTACK2)  
			SetEntPropFloat(iPlayer, Prop_Data, "m_flNextAttack", 0.0);
		else 
			SetEntPropFloat(iPlayer, Prop_Data, "m_flNextAttack", 999.0);

		// Show custom model
		switch(gZombieClass[iPlayer])
		{
			case DEFAULT_ZOMBIE:	Weapon_SetViewModelIndex(iPlayer, MODEL_ZOMBIE_CLAW_DEFAULT);
			case FAST_ZOMBIE:		Weapon_SetViewModelIndex(iPlayer, MODEL_ZOMBIE_CLAW_FAST);
			case TANK_ZOMBIE:		Weapon_SetViewModelIndex(iPlayer, MODEL_ZOMBIE_CLAW_TANK);
			case PSYH_ZOMBIE:		Weapon_SetViewModelIndex(iPlayer, MODEL_ZOMBIE_CLAW_PSYH);
		}
	}
}
// Set ViewModel and check model index
void Weapon_SetViewModelIndex(int sClient, char[] pModel)
{
	// Precache model , this is important
	int sIndex = PrecacheModel(pModel);
	
	if (sIndex < 1)
	{
		LogError("Unable to precache model '%s'", pModel);
		return;
	}
	
	// Get index of model for changing it
	pViewModelIndex[sClient] = Weapon_GetViewModelIndex(sClient);
	
	if (pViewModelIndex[sClient] < 1)
	{
		LogError("Unable to get a viewmodel index");
		return;
	}
	
	// Show effects
	ShowViewModel(pViewModelIndex[sClient], true);

	// Set Model
	SetEntProp(pViewModelIndex[sClient], Prop_Send, "m_nModelIndex", sIndex);
	ChangeEdictState(pViewModelIndex[sClient], FindDataMapOffs(pViewModelIndex[sClient], "m_nModelIndex"));

	// Update sequences and playback time for animations
	int iSequences = GetEntProp(pViewModelIndex[sClient], Prop_Send, "m_nSequence");
	
	SetEntProp(pViewModelIndex[sClient], Prop_Send, "m_nSequence", (iSequences == 2) ? 1 : iSequences); 
	SetEntPropFloat(pViewModelIndex[sClient], Prop_Send, "m_flPlaybackRate", GetEntPropFloat(pViewModelIndex[sClient], Prop_Send, "m_flPlaybackRate"));
	
	SetEntPropFloat(pViewModelIndex[sClient], Prop_Data, "m_flCycle", GetEntPropFloat(pViewModelIndex[sClient], Prop_Data, "m_flCycle"));
}

// Check and change effect of weapon entity
void ShowViewModel(int iViewModel, bool bShow)
{
    int iFlags = GetEntProp(iViewModel, Prop_Send, "m_fEffects");
    
    SetEntProp(iViewModel, Prop_Send, "m_fEffects", bShow ? iFlags & ~EF_NODRAW : iFlags | EF_NODRAW);
}

// Get entity name
int FindEntityByClassname2(int sStartEnt, char[] szClassname)
{
	while (sStartEnt > -1 && !IsValidEntity(sStartEnt)) sStartEnt--;
	return FindEntityByClassname(sStartEnt, szClassname);
}

// Get model index and prevent server from crash
int Weapon_GetViewModelIndex(int sClient)
{
	int sIndex = -1;
	
	while ((sIndex = FindEntityByClassname2(sIndex, "predicted_viewmodel")) != -1)
	{
		int Owner = GetEntPropEnt(sIndex, Prop_Send, "m_hOwner");

		if (Owner != sClient)
			continue;

		return sIndex;
	}
	return -1;
}
__________________
gubka is offline
Send a message via ICQ to gubka
gubka
Veteran Member
Join Date: Jan 2012
Location: Russia
Old 11-06-2015 , 14:52   Re: [CS:GO] Custom Viewmodel
Reply With Quote #18

Change weapon model only in this way

Quote:
new entity = MaxClients+1;

while( (entity = FindEntityByClassname(entity, "weaponworldmodel")) != -1 )
{
SetEntProp(entity, Prop_Send, "m_nModelIndex", 0);
}
__________________
gubka is offline
Send a message via ICQ to gubka
gubka
Veteran Member
Join Date: Jan 2012
Location: Russia
Old 11-06-2015 , 22:02   Re: [CS:GO] Custom Viewmodel
Reply With Quote #19

PHP Code:
new g_iWorldModel;
public OnConfigsExecuted()
g_iWorldModel = PrecacheModel("models/sticker_preview.mdl"); // Don't change

public OnClientWeaponSwitchPost(client, wpnid)
/


// Changed to:
SetEntProp(wpnid, Prop_Send, "m_nModelIndex", g_iWorldModel);

This didn't work
__________________
gubka is offline
Send a message via ICQ to gubka
CareFully
Junior Member
Join Date: Oct 2015
Old 11-07-2015 , 03:18   Re: [CS:GO] Custom Viewmodel
Reply With Quote #20

Did you try the full code thats in the op?
CareFully 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 00:05.


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