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
+69 -74
View File
@@ -34,91 +34,86 @@ public void OnMapStart()
{
g_aMovingNpc = new ArrayList();
}
else
{
char sFilename[256];
GetPluginFilename(INVALID_HANDLE, sFilename, sizeof(sFilename));
ServerCommand("sm plugins unload %s", sFilename);
}
}
public void OnEntitySpawned(int entity, const char[] classname)
{
if(!bValidMap)
return;
if(IsValidEntity(entity))
{
if(strcmp(classname, "phys_thruster") == 0)
{
char sTarget[128];
GetOutputTarget(entity, "m_OnUser1", 0, sTarget, sizeof(sTarget));
if(!sTarget[0])
return;
if(bValidMap)
{
if(IsValidEntity(entity))
{
if(strcmp(classname, "phys_thruster") == 0)
{
char sTarget[128];
GetOutputTarget(entity, "m_OnUser1", 0, sTarget, sizeof(sTarget));
if(!sTarget[0])
return;
if (StrContains(sTarget, "npc_physbox") != -1)
{
int ent = GetEntityIndexByName(sTarget, "func_physbox");
MovingNpc npc = null;
bool bAlreadyInList = false;
for (int i = 0; i < g_aMovingNpc.Length; i++)
{
MovingNpc tmp = view_as<MovingNpc>(g_aMovingNpc.Get(i));
if(tmp.entity == ent)
{
npc = tmp;
bAlreadyInList = true;
}
}
if(!bAlreadyInList)
{
npc = new MovingNpc(ent);
}
GetEntPropString(entity, Prop_Data, "m_iName", sTarget, sizeof(sTarget));
if(StrContains(sTarget, "npc_thruster_forward") != -1)
{
npc.SetThruster(true, entity);
}
else if(StrContains(sTarget, "npc_thruster_side") != -1)
{
npc.SetThruster(false, entity);
}
if (StrContains(sTarget, "npc_physbox") != -1)
{
int ent = GetEntityIndexByName(sTarget, "func_physbox");
MovingNpc npc = null;
bool bAlreadyInList = false;
for (int i = 0; i < g_aMovingNpc.Length; i++)
{
MovingNpc tmp = view_as<MovingNpc>(g_aMovingNpc.Get(i));
if(tmp.entity == ent)
{
npc = tmp;
bAlreadyInList = true;
}
}
if(!bAlreadyInList)
{
npc = new MovingNpc(ent);
}
GetEntPropString(entity, Prop_Data, "m_iName", sTarget, sizeof(sTarget));
if(StrContains(sTarget, "npc_thruster_forward") != -1)
{
npc.SetThruster(true, entity);
}
else if(StrContains(sTarget, "npc_thruster_side") != -1)
{
npc.SetThruster(false, entity);
}
if(bAlreadyInList)
{
npc.Start();
if(bAlreadyInList)
{
npc.Start();
}
else
g_aMovingNpc.Push(npc);
}
}
}
}
else
g_aMovingNpc.Push(npc);
}
}
}
}
}
public void OnEntityDestroyed(int entity)
{
if(!bValidMap)
return;
if(IsValidEntity(entity))
{
char sClassname[128];
GetEntityClassname(entity, sClassname, sizeof(sClassname));
if(strcmp(sClassname, "func_physbox") == 0)
{
for (int i = 0; i < g_aMovingNpc.Length; i++)
{
MovingNpc npc = view_as<MovingNpc>(g_aMovingNpc.Get(i));
if(npc.entity == entity)
{
if(bValidMap)
{
if(IsValidEntity(entity))
{
char sClassname[128];
GetEntityClassname(entity, sClassname, sizeof(sClassname));
if(strcmp(sClassname, "func_physbox") == 0)
{
for (int i = 0; i < g_aMovingNpc.Length; i++)
{
MovingNpc npc = view_as<MovingNpc>(g_aMovingNpc.Get(i));
if(npc.entity == entity)
{
npc.Stop();
g_aMovingNpc.Erase(i);
break;
}
}
}
}
npc.Stop();
g_aMovingNpc.Erase(i);
break;
}
}
}
}
}
}
@@ -135,4 +130,4 @@ public void OnMapEnd()
delete g_aMovingNpc;
}
bValidMap = false;
}
}