mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-05 20:03:20 +00:00
l4d2_population_control: Properly precache models
This commit is contained in:
parent
e94eb6bd05
commit
c1c4df5bf4
2 changed files with 15 additions and 5 deletions
Binary file not shown.
|
@ -22,6 +22,16 @@ static ConVar hPercentTotal;
|
||||||
static ConVar hPercentClown;
|
static ConVar hPercentClown;
|
||||||
static ConVar hPercentMud;
|
static ConVar hPercentMud;
|
||||||
|
|
||||||
|
#define COMMON_MODELS_COUNT 2
|
||||||
|
static char INFECTED_MODELS[COMMON_MODELS_COUNT][] = {
|
||||||
|
"models/infected/common_male_clown.mdl",
|
||||||
|
"models/infected/common_male_mud.mdl"
|
||||||
|
};
|
||||||
|
enum CommonTypes {
|
||||||
|
Common_Clown,
|
||||||
|
Common_Mud
|
||||||
|
};
|
||||||
|
|
||||||
public void OnPluginStart() {
|
public void OnPluginStart() {
|
||||||
EngineVersion g_Game = GetEngineVersion();
|
EngineVersion g_Game = GetEngineVersion();
|
||||||
if(g_Game != Engine_Left4Dead2) {
|
if(g_Game != Engine_Left4Dead2) {
|
||||||
|
@ -34,21 +44,21 @@ public void OnPluginStart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnMapStart() {
|
public void OnMapStart() {
|
||||||
PrecacheModel("models/infected/common_male_clown.mdl");
|
for(int i = 0; i < COMMON_MODELS_COUNT; i++) {
|
||||||
PrecacheModel("models/infected/common_male_mud.mdl");
|
PrecacheModel(INFECTED_MODELS[i], true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnEntityCreated(int entity, const char[] classname) {
|
public void OnEntityCreated(int entity, const char[] classname) {
|
||||||
if (StrEqual(classname, "infected")) {
|
if (StrEqual(classname, "infected")) {
|
||||||
char m_ModelName[PLATFORM_MAX_PATH];
|
char m_ModelName[PLATFORM_MAX_PATH];
|
||||||
GetEntPropString(entity, Prop_Data, "m_ModelName", m_ModelName, sizeof(m_ModelName));
|
GetEntPropString(entity, Prop_Data, "m_ModelName", m_ModelName, sizeof(m_ModelName));
|
||||||
PrintToConsoleAll("Infected -> %s", m_ModelName);
|
|
||||||
if(GetRandomFloat() <= hPercentTotal.FloatValue) {
|
if(GetRandomFloat() <= hPercentTotal.FloatValue) {
|
||||||
float spawnPercentage = GetRandomFloat();
|
float spawnPercentage = GetRandomFloat();
|
||||||
if(spawnPercentage <= hPercentClown.FloatValue) {
|
if(spawnPercentage <= hPercentClown.FloatValue) {
|
||||||
SetEntityModel(entity, "models/infected/common_male_clown.mdl");
|
SetEntityModel(entity, INFECTED_MODELS[Common_Clown]);
|
||||||
}else if(spawnPercentage <= hPercentMud.FloatValue) {
|
}else if(spawnPercentage <= hPercentMud.FloatValue) {
|
||||||
SetEntityModel(entity, "models/infected/common_male_mud.mdl");
|
SetEntityModel(entity, INFECTED_MODELS[Common_Mud]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue