mirror of
https://github.com/hermansimensen/eventqueue-fix.git
synced 2025-12-06 18:08:27 +00:00
fix unable to find entity bug
avoid standard sourcemod behaviour and get the raw pointer instead.
This commit is contained in:
parent
461f508057
commit
afcde35d3c
@ -141,13 +141,13 @@ void LoadDHooks()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
PrepSDKCall_SetFromConf(gamedataConf, SDKConf_Signature, "FindEntityByName");
|
PrepSDKCall_SetFromConf(gamedataConf, SDKConf_Signature, "FindEntityByName");
|
||||||
PrepSDKCall_SetReturnInfo(SDKType_CBaseEntity, SDKPass_Pointer);
|
PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_ByValue);
|
||||||
PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer, VDECODE_FLAG_ALLOWNULL | VDECODE_FLAG_ALLOWWORLD);
|
PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer, VDECODE_FLAG_ALLOWNULL | VDECODE_FLAG_ALLOWWORLD);
|
||||||
PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
|
PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
|
||||||
PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer, VDECODE_FLAG_ALLOWNULL | VDECODE_FLAG_ALLOWWORLD);
|
PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer, VDECODE_FLAG_ALLOWNULL | VDECODE_FLAG_ALLOWWORLD);
|
||||||
PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer, VDECODE_FLAG_ALLOWNULL | VDECODE_FLAG_ALLOWWORLD);
|
PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer, VDECODE_FLAG_ALLOWNULL | VDECODE_FLAG_ALLOWWORLD);
|
||||||
PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer, VDECODE_FLAG_ALLOWNULL | VDECODE_FLAG_ALLOWWORLD);
|
PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer, VDECODE_FLAG_ALLOWNULL | VDECODE_FLAG_ALLOWWORLD);
|
||||||
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
|
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_ByValue);
|
||||||
g_hFindEntityByName = EndPrepSDKCall();
|
g_hFindEntityByName = EndPrepSDKCall();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -326,82 +326,44 @@ public Action OnTrigger(const char[] output, int caller, int activator, float de
|
|||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int FindEntityByName(int startEntity, char[] targetname, int searchingEnt, int activator, int caller)
|
||||||
|
{
|
||||||
|
Address targetEntityAddr = SDKCall(g_hFindEntityByName, startEntity, targetname, searchingEnt, activator, caller, 0);
|
||||||
|
|
||||||
|
if(targetEntityAddr == Address_Null)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return EntRefToEntIndex(EntityToBCompatRef(targetEntityAddr));
|
||||||
|
}
|
||||||
|
|
||||||
public void ServiceEvent(event_t event)
|
public void ServiceEvent(event_t event)
|
||||||
{
|
{
|
||||||
SetVariantString(event.variantValue);
|
SetVariantString(event.variantValue);
|
||||||
int targetEntity;
|
int targetEntity = FindEntityByName(-1, event.target, event.caller, event.activator, event.caller);
|
||||||
if(!strcmp("!activator", event.target, false))
|
|
||||||
{
|
if(targetEntity != -1)
|
||||||
targetEntity = event.activator;
|
|
||||||
AcceptEntityInput(targetEntity, event.targetInput, event.activator, event.caller, event.outputID);
|
|
||||||
}
|
|
||||||
else if(!strcmp("!caller", event.target, false))
|
|
||||||
{
|
|
||||||
targetEntity = event.caller;
|
|
||||||
AcceptEntityInput(targetEntity, event.targetInput, event.activator, event.caller, event.outputID);
|
|
||||||
}
|
|
||||||
else if(!strcmp("!self", event.target, false))
|
|
||||||
{
|
|
||||||
targetEntity = event.caller;
|
|
||||||
AcceptEntityInput(targetEntity, event.targetInput, event.activator, event.caller, event.outputID);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!strcmp("kill", event.targetInput, false))
|
if(!strcmp("kill", event.targetInput, false))
|
||||||
{
|
{
|
||||||
for(int i = 0; i < 4; i++)
|
for(int i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
targetEntity = SDKCall(g_hFindEntityByName, 0, event.target, event.caller, event.activator, event.caller, 0);
|
targetEntity = FindEntityByName(-1, event.target, event.caller, event.activator, event.caller);
|
||||||
if(targetEntity != -1)
|
if(targetEntity != -1)
|
||||||
{
|
|
||||||
AcceptEntityInput(targetEntity, event.targetInput, event.activator, event.caller, event.outputID);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
//sometimes the call fails and we must use this slower method for now.
|
|
||||||
for(int y = 0; y < GetMaxEntities()*2; y++)
|
|
||||||
{
|
{
|
||||||
char name[32];
|
PrintToChat(event.activator, "killing!");
|
||||||
|
AcceptEntityInput(targetEntity, event.targetInput, event.activator, event.caller, event.outputID);
|
||||||
if(IsValidEntity(y))
|
} else
|
||||||
GetEntPropString(y, Prop_Data, "m_iName", name, sizeof(name));
|
break;
|
||||||
|
|
||||||
if(!strcmp(event.target, name, false))
|
|
||||||
{
|
|
||||||
AcceptEntityInput(y, event.targetInput, event.activator, event.caller, event.outputID);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
targetEntity = SDKCall(g_hFindEntityByName, -1, event.target, -1, -1, -1, 0);
|
AcceptEntityInput(targetEntity, event.targetInput, event.activator, event.caller, event.outputID);
|
||||||
if(targetEntity != -1)
|
|
||||||
{
|
|
||||||
AcceptEntityInput(targetEntity, event.targetInput, event.activator, event.caller, event.outputID);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//if we still can't find the target use this slower method.
|
|
||||||
for(int i = 0; i < GetMaxEntities()*2; i++)
|
|
||||||
{
|
|
||||||
char name[32];
|
|
||||||
|
|
||||||
if(IsValidEntity(i))
|
|
||||||
GetEntPropString(i, Prop_Data, "m_iName", name, sizeof(name));
|
|
||||||
|
|
||||||
if(!strcmp(event.target, name, false))
|
|
||||||
{
|
|
||||||
AcceptEntityInput(i, event.targetInput, event.activator, event.caller, event.outputID);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
#if defined DEBUG
|
#if defined DEBUG
|
||||||
PrintToChat(event.activator, "Performing output: %s, %i, %i, %s %s, %i, %f", event.target, targetEntity, event.caller, event.targetInput, event.variantValue, event.outputID, GetGameTime());
|
PrintToChat(event.activator, "Performing output: %s, %i, %i, %s %s, %i, %f", event.target, targetEntity, event.caller, event.targetInput, event.variantValue, event.outputID, GetGameTime());
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user