So, in L4D1 Campaigns, it is possible to use L4D2 survivors thanks to Left4Downtown2 being able to force the L4D2 set, however this does not load the L4D2 survivor arms icons, so I tried to make a plugin to get around this issue, keeping in mind that the actual ViewModel entity of the player is obtained via the Viewmodelindex netprop.
PHP Code:
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "1.0"
static const String:MODEL_NICK_ARMS[] = "models/weapons/arms/v_arms_gambler_new.mdl";
static const String:MODEL_ROCHELLE_ARMS[] = "models/weapons/arms/v_arms_producer_new.mdl";
static const String:MODEL_COACH_ARMS[] = "models/weapons/arms/v_arms_coach_new.mdl";
static const String:MODEL_ELLIS_ARMS[] = "models/weapons/arms/v_arms_mechanic_new.mdl";
public Plugin:myinfo =
{
name = "ViewModelTest",
author = "DeathChaos",
description = " ",
version = PLUGIN_VERSION,
}
public OnPluginStart()
{
RegConsoleCmd("sm_v", ViewModelTest);
}
public OnMapStart()
{
CheckModelPreCache(MODEL_NICK_ARMS);
CheckModelPreCache(MODEL_ROCHELLE_ARMS);
CheckModelPreCache(MODEL_COACH_ARMS);
CheckModelPreCache(MODEL_ELLIS_ARMS);
}
public Action:ViewModelTest(client, args)
{
if (!IsSurvivor(client))
{
return;
}
new ViewModelIndex = GetEntProp(client, Prop_Send, "m_hViewModel");
new String:model[PLATFORM_MAX_PATH] = "";
GetEntPropString(client, Prop_Data, "m_ModelName", model, sizeof(model));
new String:message[PLATFORM_MAX_PATH] = "";
Format(message, sizeof(message), "Your Current Model Index is : %i and your model is %s", ViewModelIndex, model);
PrintToChat(client, message);
if (IsValidEntity(ViewModelIndex))
{
DispatchKeyValue(ViewModelIndex, "CharacterViewmodelAddon", MODEL_NICK_ARMS);
}
}
stock bool:IsSurvivor(client)
{
if (client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2)
{
return true;
}
return false;
}
stock CheckModelPreCache(const String:Modelfile[])
{
if (!IsModelPrecached(Modelfile))
{
PrecacheModel(Modelfile, true);
PrintToServer("Precaching Model:%s", Modelfile);
}
}
However, For some reason, the viewmodel entity is reported as an invalid entity.
Any ideas as to why?
__________________