Raised This Month: $12 Target: $400
 3% 

[CS:GO] Custom Viewmodel


Post New Thread Reply   
 
Thread Tools Display Modes
Andersso
Member
Join Date: Nov 2009
Location: E8 2A 2A 2A 2A
Old 12-12-2015 , 06:24   Re: [CS:GO] Custom Viewmodel
Reply With Quote #61

You can do it in two ways:
* Use Crowbar and decompile the model and change the path of the view model in the generated qc file, and then compile it again
* Rename all "model files" to something new, and use a hex editor to change the path inside the mdl file

Just to remember, original csgo view models don't have built in arm models, it is however possible to fix this in the qc file (when decompiled). Don't have the code for doing it as I am writing this though

If you have garrysmod, you can download a lot of models from here
Andersso is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 12-26-2015 , 14:20   Re: [CS:GO] Custom Viewmodel
Reply With Quote #62

Here a interface using this snippet -> https://forums.alliedmods.net/showthread.php?t=276697
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.

Franc1sco is offline
Send a message via MSN to Franc1sco
Epal
Junior Member
Join Date: Feb 2016
Old 07-08-2016 , 15:44   Re: [CS:GO] Custom Viewmodel
Reply With Quote #63

how add
[code]
new g_iWorldSMGModel; //precached model index

public OnEntityCreated(entid){
decl String:szWpn[64];
GetEntityClassname(entid, szWpn, sizeof(szWpn));
if(StrEqual(szWpn, "weapon_mac10")){
SDKHook(entid, SDKHook_SpawnPost, OnEntitySpawn);
}
}
public OnEntitySpawn(entid){

new WMid = GetEntPropEnt(entid, Prop_Send, "m_hWeaponWorldModel")
SetEntProp(WMid, Prop_Send, "m_nModelIndex", g_iWorldSMGModel);
}
/[code]

for this
[code]
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>

#define MODEL "models/weapons/epal.mdl" // custom view model

new g_PVMid[MAXPLAYERS]; // Predicted ViewModel ID's
new g_iSMGModel; // Custom ViewModel index


public OnPluginStart()
{
HookEvent("player_spawn", Event_PlayerSpawn);
}

public OnConfigsExecuted()
{
g_iSMGModel = PrecacheModel("models/weapons/epal_.mdl"); // Custom model
}

public OnClientPostAdminCheck(client){
SDKHook(client, SDKHook_WeaponSwitchPost, OnClientWeaponSwitchPost);
}

public OnClientWeaponSwitchPost(client, wpnid)
{

decl String:szWpn[64];
GetEntityClassname(wpnid,szWpn,sizeof(szWpn)) ;

if(StrEqual(szWpn, "weapon_galilar")){
SetEntProp(wpnid, Prop_Send, "m_nModelIndex", 0);
SetEntProp(g_PVMid[client], Prop_Send, "m_nModelIndex", g_iSMGModel);
}
}

public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
g_PVMid[client] = Weapon_GetViewModelIndex(client, -1);

}

// Thanks to gubka for these 2 functions below.

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

if (Owner != client)
continue;

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

public OnMapStart()
{
g_iSMGModel = PrecacheModel(MODEL); // Custom model

// model downloads

}
/[code]
Epal is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 10-30-2016 , 03:34   Re: [CS:GO] Custom Viewmodel
Reply With Quote #64

Quote:
Originally Posted by Andersso View Post
Thought I could promote my own script here for changing view model..

It's been on GitHub for quite some time, but it was never finished. I have now spent some more time on the project and hopefully it's more "work" and less "not work"

I wrote this script in goal of having no glitches at all, and a lot of voodoo magic has gone in to making that possible. (At least, as close as possible)
However, the API and file config should be easy enough for most people to use

Not much time has gone into testing. Maybe I could get some help with that

Source: https://github.com/Andersso/SM-WeaponModels

Here is some old video i posted some time ago on a different thread

Mini example of API:
PHP Code:
#include <sourcemod>
#include <weaponmodels>

public void OnMapStart()
{
    
WeaponModels_AddWeaponByClassName("weapon_knife""models/weapons/v_my_custom_knife.mdl"NULL_STRINGWeaponModels_OnWeapon);
}

public 
bool WeaponModels_OnWeapon(int weaponIndexint clientint weapon, const char[] classNameint itemDefIndex)
{
    return 
true;

I'm using this in a plugin, and it works great in my test server. In a live server though, people's weapons occasionally disappear. They can fire, but no view model is present. Any idea why that is? Also, giant shadows appear in the server randomly, and only when the plugin is running. Weird stuff....
__________________
ThatOneGuy is offline
Dkmuniz
Senior Member
Join Date: Jun 2013
Old 11-08-2016 , 23:23   Re: [CS:GO] Custom Viewmodel
Reply With Quote #65

Quote:
Originally Posted by ThatOneGuy View Post
I'm using this in a plugin, and it works great in my test server. In a live server though, people's weapons occasionally disappear. They can fire, but no view model is present. Any idea why that is? Also, giant shadows appear in the server randomly, and only when the plugin is running. Weird stuff....
"Arm model also needs to be included in custom view model"
Dkmuniz is offline
Dkmuniz
Senior Member
Join Date: Jun 2013
Old 11-08-2016 , 23:25   Re: [CS:GO] Custom Viewmodel
Reply With Quote #66

https://github.com/Andersso/SM-WeaponModels
Nice One, think this is better than franc1sco First-Person-View-Models-Interface

Last edited by Dkmuniz; 11-08-2016 at 23:25.
Dkmuniz is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 11-09-2016 , 01:01   Re: [CS:GO] Custom Viewmodel
Reply With Quote #67

Quote:
Originally Posted by Dkmuniz View Post
"Arm model also needs to be included in custom view model"
Let me be more clear. The models are and show in most situations. After further testing, we figured out that the models disappear when someone with the model, who was in a previous round (i.e. their custom model was set) spectates someone without a custom model for one of their equipped weapons (does not need to be active). The living player (the one without the custom model) cant see a view model, so their arms, hands, and weapon are invisible, though they can still fire. Have posted on Andersso's github repository under issues...looks like someone else posted it and their issue was closed without resolution : / . I've put a lot of time into debugging it (hence being able to identify the source of when it happens, as noted above). Additionally, it seems to be related to the postthink code, since the disappearing doesnt necessarily happen on weapon switch, and sometime happens when the player is standing still quite a few seconds after spawn or any weapon switches.
__________________
ThatOneGuy is offline
FroGeX
Senior Member
Join Date: Aug 2020
Old 01-24-2021 , 01:29   Re: [CS:GO] Custom Viewmodel
Reply With Quote #68

Is possible chamge weapons sounds too? Shot, reload...

Last edited by FroGeX; 01-24-2021 at 01:29.
FroGeX is offline
asaswwda
Junior Member
Join Date: Jun 2020
Old 01-11-2022 , 04:24   Re: [CS:GO] Custom Viewmodel
Reply With Quote #69

Not work in NMRiH
asaswwda is offline
Reply


Thread Tools
Display Modes

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 05:55.


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