Its a plugin I made for sourcemod
#include <sourcemod>
#include <sdktools>
static const String:EntityClassNames[3][] =
{
"item_healthkit_full",
"item_healthkit_medium",
"item_healthkit_small"
}
static const String:EntityModelReplacement[3][] =
{
"models/necrophix_valentine/necrophix_valentine_lg.mdl",
"models/necrophix_valentine/necrophix_valentine_mid.mdl",
"models/necrophix_valentine/necrophix_valentine_sm.mdl"
}
public Plugin:myinfo =
{
name = "Valentines Day Items!",
author = "Nut",
description = "",
version = "0.1",
url = ""
}
public OnPluginStart()
HookEventEx("teamplay_round_start", event_RoundStart, EventHookMode_PostNoCopy);
public OnMapStart()
for (new i = 0; i < 3; i++)
{
PrintToServer("PRECACHING %s", EntityModelReplacement[i]);
PrecacheModelResources(EntityModelReplacement[i]);
}
public Action:event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
new ent = -1;
for (new i = 0; i < 3; i++)
while((ent = FindEntityByClassname(ent, EntityClassNames[i])) != -1)
SetEntityModel(ent, EntityModelReplacement[i]);
}
//Stocks from Presents
stock PrecacheModelResources(String:strFile[])
{
decl String:strBuffer[PLATFORM_MAX_PATH];
decl Handle:hStream;
Format(strBuffer, sizeof(strBuffer), "%s.res", strFile);
if ((hStream = OpenFile(strBuffer, "r")) == INVALID_HANDLE)
return;
while(!IsEndOfFile(hStream))
{
ReadFileLine(hStream, strBuffer, sizeof(strBuffer));
CleanString(strBuffer);
if (FileExists(strBuffer, true) || FileExists(strBuffer, false))
{
if (StrContains(strBuffer, ".vmt", false) != -1) PrecacheDecal(strBuffer, true);
else if (StrContains(strBuffer, ".mdl", false) != -1) PrecacheModel(strBuffer, true);
else if (StrContains(strBuffer, ".pcf", false) != -1) PrecacheGeneric(strBuffer, true);
AddFileToDownloadsTable(strBuffer);
}
}
}
stock PrecacheSoundResources(String:strFile[])
{
decl String:strBuffer[PLATFORM_MAX_PATH];
Format(strBuffer, sizeof(strBuffer), "sound/%s", strFile);
PrecacheSound(strFile, true);
AddFileToDownloadsTable(strBuffer);
}
stock CleanString(String:strBuffer[])
{
new iLength = strlen(strBuffer);
for (new iPos=0; iPos<iLength; iPos++)
switch(strBuffer[iPos])
{
case '\r', '\n', '\t': strBuffer[iPos] = ' ';
}
TrimString(strBuffer);
}