[CS:GO] Weapon Model

qubka

Zombie Plague Разработчик
Сообщения
245
Реакции
244
Для зомби мода нужно изменить модель, для ножа только , попытался использовать стандартную но иногда видны проблески черные , я уже и через синк пробовал и по другому все равно этот баг есть, кто может помочь

C-подобный:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

new viewModelweaponindex[MAXPLAYERS+1];

public Plugin:myinfo =
{
	name = "0",
	author = "0",
	description = "0",
	version = "0",
	url = "0"
};

public void OnMapStart()
{
	PrecacheModel("models/weapons/v_knife_gg.mdl");
}

public void OnClientPutInServer(client)
{
	SDKHook(client, SDKHook_PreThinkPost, OnThinkPost);
	SDKHook(client, SDKHook_PostThinkPost, OnThinkPost);
}

public OnClientDisconnect_Post(client)
{
	viewModelweaponindex[client] = 0;
}

public OnThinkPost(client)
{
	if (IsClientConnected(client))
	{
		if(IsClientInGame(client))
		{
			if(IsPlayerAlive(client))
			{
				decl String:wEntity[128];

				new ActiveWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
	
				GetEdictClassname(ActiveWeapon, wEntity, sizeof(wEntity));
				
				// If weapon is a knife, then allow pickup.
				if (StrEqual(wEntity, "weapon_knife"))
				{
					Weapon_SetViewModelIndex(client, "models/weapons/v_knife_gg.mdl");
				}
			}
		}
	}
}

Weapon_SetViewModelIndex(client, String:Model[])
{
	new index = PrecacheModel(Model);
	
	if (index < 1)
	{
		LogError("Unable to precache model '%s'", Model);
		return;
	}
	
	viewModelweaponindex[client] = Weapon_GetViewModelIndex(client);
	
	if (viewModelweaponindex[client] < 1)
	{
		LogError("Unable to get a viewmodel index");
		return;
	}
	
	SetEntProp(viewModelweaponindex[client], Prop_Send, "m_nModelIndex", index);
	ChangeEdictState(viewModelweaponindex[client], FindDataMapOffs(viewModelweaponindex[client], "m_nModelIndex"));
}

Weapon_GetViewModelIndex(client)
{
	new index = -1;
	while ((index = FindEntityByClassname2(index, "predicted_viewmodel")) != -1)
	{
		new Owner = GetEntPropEnt(index, Prop_Send, "m_hOwner");
		new ClientWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
		new Weapon = GetEntPropEnt(index, Prop_Send, "m_hWeapon");
		if (Owner != client)
			continue;
		if (ClientWeapon != Weapon)
			continue;
		return index;
	}
	return -1;
}

stock FindEntityByClassname2(startEnt, const String:classname[])
{
	while (startEnt > -1 && !IsValidEntity(startEnt)) startEnt--;
	return FindEntityByClassname(startEnt, classname);
}
 
Сверху Снизу