PHP Code:
/**
* Activates an entity (CBaseAnimating::Activate)
*
* @param entity Entity index.
* @noreturn
* @error Invalid entity or lack of mod support.
*/
native ActivateEntity(entity);
Why do we need the info_target to animate?
Here's 2 old stocks I have and a rewrite of your thing.
PHP Code:
stock KillEntityIn(iEnt, Float:flSeconds)
{
decl String:szAddOutput[32];
Format(szAddOutput, sizeof(szAddOutput), "OnUser1 !self,Kill,,%0.2f,1", flSeconds);
SetVariantString(szAddOutput);
AcceptEntityInput(iEnt, "AddOutput");
AcceptEntityInput(iEnt, "FireUser1");
}
/*
Fire entity input on an entity after a certain delay
*/
stock DelayEntityInput(iEnt, const String:szInput[], const Float:flSeconds, const String:szVariant[] = "")
{
decl String:szAddOutput[128];
Format(szAddOutput, sizeof(szAddOutput), "OnUser1 !self,%s,%s,%0.2f,1", szInput, szVariant, flSeconds);
SetVariantString(szAddOutput);
AcceptEntityInput(iEnt, "AddOutput");
AcceptEntityInput(iEnt, "FireUser1");
}
stock FireEntityInput(const String:szTargetname[], const String:szInput[], const String:szParam[]="", const Float:flDelay=0.0)
{
decl String:szBuffer[255];
Format(szBuffer, sizeof(szBuffer), "OnUser1 %s:%s:%s:%0.2f:1", szTargetname, szInput, szParam, flDelay);
static iSaveEnt = EntIndexToEntRef(SpawnEntityByName("info_target"));
new iEnt = EntRefToEntIndex(iSaveEnt); // Dummy entity. (Pretty sure every Source game has this.)
if (iEnt == -1 || !IsValidEntity(iEnt))
{
iSaveEnt = EntIndexToEntRef(SpawnEntityByName("info_target"));
iEnt = EntRefToEntIndex(iSaveEnt);
if (iEnt == -1 || !IsValidEntity(iEnt))
{
return false; // Failed to recreate dummy entity
}
}
SetVariantString(szBuffer);
AcceptEntityInput(iEnt, "AddOutput");
AcceptEntityInput(iEnt, "FireUser1");
//AcceptEntityInput(iEnt, "Kill");
return true;
}
stock SpawnEntityByName(const String:szClassname[], iForceEdictIndex = -1)
{
new iEnt = CreateEntityByName(szClassname, iForceEdictIndex);
if (iEnt != -1)
{
DispatchSpawn(iEnt);
// ActivateEntity(iEnt);
}
return iEnt;
}
__________________