From a4a35856c08803d411cc99fd39eb931657d86a7d Mon Sep 17 00:00:00 2001 From: BotoX Date: Thu, 17 Oct 2019 12:05:26 +0200 Subject: [PATCH] DamageProxy: Add _hammmerid->Team to assign teams to generic entities --- DamageProxy/scripting/DamageProxy.sp | 40 +++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/DamageProxy/scripting/DamageProxy.sp b/DamageProxy/scripting/DamageProxy.sp index 15a85bcd..2c0f0262 100644 --- a/DamageProxy/scripting/DamageProxy.sp +++ b/DamageProxy/scripting/DamageProxy.sp @@ -14,7 +14,7 @@ public Plugin myinfo = name = "DamageProxy", author = "BotoX", description = "", - version = "0.0", + version = "0.2", url = "" }; @@ -117,6 +117,14 @@ public void OnMapStart() if(iKnife > 0) OnWeaponEquipped(client, iKnife); } + + int entity = INVALID_ENT_REFERENCE; + while((entity = FindEntityByClassname(entity, "*")) != INVALID_ENT_REFERENCE) + { + char sClassname[64]; + if(GetEntityClassname(entity, sClassname, sizeof(sClassname))) + OnEntitySpawned(entity, sClassname); + } } public void OnClientPutInServer(int client) @@ -195,6 +203,36 @@ public void OnWeaponDropped(int client, int entity) } } +public void OnEntitySpawned(int entity, const char[] classname) +{ + if(!g_Config) + return; + + if(entity < 0 || entity >= sizeof(g_iPhysboxToClient)) + return; + + if(!IsValidEntity(entity)) + return; + + int iHammerID = GetEntProp(entity, Prop_Data, "m_iHammerID"); + if(!iHammerID) + return; + + char sHammerID[16] = "_"; + IntToString(iHammerID, sHammerID[1], sizeof(sHammerID) - 1); + + g_Config.Rewind(); + if(!g_Config.JumpToKey(sHammerID)) + return; + + int iTeam = g_Config.GetNum("Team", 0); + + if(iTeam >= 1 && iTeam <= 3) + { + g_iPhysboxToClient[entity] = -iTeam; + } +} + public void OnEntityDestroyed(int entity) { if(entity >= 0 && entity < sizeof(g_iPhysboxToClient))