added functionality to check the map on a bunch of map specific plugins. this way we dont have to load/unload plugins that usually causes slow map changes or even causes crashes. momsurffix was compiled with sourcemod 1.11

This commit is contained in:
2024-08-04 16:56:23 +02:00
parent 0e5cc3175c
commit a296dd400c
8 changed files with 1575 additions and 882 deletions
+98 -102
View File
@@ -36,83 +36,77 @@ public void OnMapStart()
HookEvent("round_end", OnRoundEnd, EventHookMode_PostNoCopy);
g_aEyes = new ArrayList();
}
else
{
char sFilename[256];
GetPluginFilename(INVALID_HANDLE, sFilename, sizeof(sFilename));
ServerCommand("sm plugins unload %s", sFilename);
}
}
public void OnRoundStart(Event event, const char[] name, bool dontBroadcast)
{
if(!bValidMap)
return;
g_Chess = new Chess(GetEntityIndexByName("GreenStart", "path_track"), GetEntityIndexByName("GreenEnd", "path_track"),
GetEntityIndexByName("PurpleStart", "path_track"), GetEntityIndexByName("PurpleEnd", "path_track"));
int tmp = GetEntityIndexByName("GreenEnd", "path_track");
if(bValidMap)
{
g_Chess = new Chess(GetEntityIndexByName("GreenStart", "path_track"), GetEntityIndexByName("GreenEnd", "path_track"),
GetEntityIndexByName("PurpleStart", "path_track"), GetEntityIndexByName("PurpleEnd", "path_track"));
int tmp = GetEntityIndexByName("GreenEnd", "path_track");
HookSingleEntityOutput(tmp, "OnPass", OnGreenEndPass);
tmp = GetEntityIndexByName("PurpleEnd", "path_track");
HookSingleEntityOutput(tmp, "OnPass", OnGreenEndPass);
tmp = GetEntityIndexByName("PurpleEnd", "path_track");
HookSingleEntityOutput(tmp, "OnPass", OnPurpleEndPass);
tmp = GetEntityIndexByHammerID(92835, "func_button");
HookSingleEntityOutput(tmp, "OnPass", OnPurpleEndPass);
tmp = GetEntityIndexByHammerID(92835, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton1);
tmp = GetEntityIndexByHammerID(92838, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton1);
tmp = GetEntityIndexByHammerID(92838, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton2);
tmp = GetEntityIndexByHammerID(92841, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton2);
tmp = GetEntityIndexByHammerID(92841, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton3);
tmp = GetEntityIndexByHammerID(92844, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton3);
tmp = GetEntityIndexByHammerID(92844, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton4);
tmp = GetEntityIndexByHammerID(92850, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton4);
tmp = GetEntityIndexByHammerID(92850, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton5);
tmp = GetEntityIndexByHammerID(92847, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton6);
tmp = GetEntityIndexByHammerID(92853, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton5);
tmp = GetEntityIndexByHammerID(92847, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton6);
tmp = GetEntityIndexByHammerID(92853, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton7);
tmp = GetEntityIndexByHammerID(92856, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton7);
tmp = GetEntityIndexByHammerID(92856, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton8);
tmp = GetEntityIndexByHammerID(92013, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton8);
tmp = GetEntityIndexByHammerID(92013, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton1);
tmp = GetEntityIndexByHammerID(92084, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton1);
tmp = GetEntityIndexByHammerID(92084, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton2);
tmp = GetEntityIndexByHammerID(91906, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton2);
tmp = GetEntityIndexByHammerID(91906, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton3);
tmp = GetEntityIndexByHammerID(92081, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton3);
tmp = GetEntityIndexByHammerID(92081, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton4);
tmp = GetEntityIndexByHammerID(92016, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton4);
tmp = GetEntityIndexByHammerID(92016, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton5);
tmp = GetEntityIndexByHammerID(92075, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton5);
tmp = GetEntityIndexByHammerID(92075, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton6);
tmp = GetEntityIndexByHammerID(89814, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton6);
tmp = GetEntityIndexByHammerID(89814, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton7);
tmp = GetEntityIndexByHammerID(92046, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton7);
tmp = GetEntityIndexByHammerID(92046, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton8);
tmp = GetEntityIndexByHammerID(89040, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton8);
tmp = GetEntityIndexByHammerID(89040, "func_button");
HookSingleEntityOutput(tmp, "OnPressed", OnPressedTrig, true);
tmp = GetEntityIndexByHammerID(490936, "trigger_push");
HookSingleEntityOutput(tmp, "OnPressed", OnPressedTrig, true);
tmp = GetEntityIndexByHammerID(490936, "trigger_push");
HookSingleEntityOutput(tmp, "OnStartTouch", OnPushTrigger);
tmp = GetEntityIndexByHammerID(445713, "trigger_push");
HookSingleEntityOutput(tmp, "OnStartTouch", OnPushTrigger);
tmp = GetEntityIndexByHammerID(445713, "trigger_push");
HookSingleEntityOutput(tmp, "OnStartTouch", OnPushTrigger2);
HookSingleEntityOutput(tmp, "OnStartTouch", OnPushTrigger2);
}
}
public void OnPushTrigger2(const char[] output, int caller, int activator, float delay)
@@ -304,29 +298,30 @@ public void OnPurpleEndPass(const char[] output, int caller, int activator, floa
public void OnEntitySpawned(int entity, const char[] classname)
{
if(!bValidMap)
return;
if(IsValidEntity(entity))
{
if(strcmp(classname, "func_breakable") == 0)
{
char sName[128];
GetEntPropString(entity, Prop_Data, "m_iName", sName, sizeof(sName));
if(!sName[0])
return;
int pos = FindCharInString(sName, '&', true);
if(pos != -1)
{ sName[pos] = 0;
if(strcmp(sName, "EyeBoss") == 0)
{
if(bValidMap)
{
if(IsValidEntity(entity))
{
if(strcmp(classname, "func_breakable") == 0)
{
char sName[128];
GetEntPropString(entity, Prop_Data, "m_iName", sName, sizeof(sName));
if(!sName[0])
return;
int pos = FindCharInString(sName, '&', true);
if(pos != -1)
{ sName[pos] = 0;
if(strcmp(sName, "EyeBoss") == 0)
{
Eye eye = new Eye(entity);
HookSingleEntityOutput(entity, "OnUser2", OnEyeMove);
g_aEyes.Push(eye);
}
}
}
}
Eye eye = new Eye(entity);
HookSingleEntityOutput(entity, "OnUser2", OnEyeMove);
g_aEyes.Push(eye);
}
}
}
}
}
}
public void OnEyeMove(const char[] output, int caller, int activator, float delay)
@@ -345,33 +340,34 @@ public void OnEyeMove(const char[] output, int caller, int activator, float dela
public void OnEntityDestroyed(int entity)
{
if(!bValidMap)
return;
if(IsValidEntity(entity))
{
char sClassname[64];
GetEntityClassname(entity, sClassname, sizeof(sClassname));
if(strcmp(sClassname, "func_breakable") == 0)
{
char sName[128];
GetEntPropString(entity, Prop_Data, "m_iName", sName, sizeof(sName));
if(!sName[0])
return;
if(StrContains(sName, "EyeBoss") != -1)
{
for (int i = 0; i < g_aEyes.Length; i++)
{
Eye tmp = view_as<Eye>(g_aEyes.Get(i));
if(entity == tmp.entity)
{
if(bValidMap)
{
if(IsValidEntity(entity))
{
char sClassname[64];
GetEntityClassname(entity, sClassname, sizeof(sClassname));
if(strcmp(sClassname, "func_breakable") == 0)
{
char sName[128];
GetEntPropString(entity, Prop_Data, "m_iName", sName, sizeof(sName));
if(!sName[0])
return;
if(StrContains(sName, "EyeBoss") != -1)
{
for (int i = 0; i < g_aEyes.Length; i++)
{
Eye tmp = view_as<Eye>(g_aEyes.Get(i));
if(entity == tmp.entity)
{
delete tmp;
g_aEyes.Erase(i);
}
}
}
}
}
delete tmp;
g_aEyes.Erase(i);
}
}
}
}
}
}
}
public void Cleanup()
@@ -402,4 +398,4 @@ public void OnMapEnd()
UnhookEvent("round_end", OnRoundEnd, EventHookMode_PostNoCopy);
}
bValidMap = false;
}
}