|
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
|
05-06-2021
, 13:26
Re: [L4D2] Offset to get duration of the "insect_swarm" entity
|
#3
|
Quote:
Originally Posted by BHaType
CInsectSwarm inherits from the CInferno class that stores the creation timestamp
Elapsed time = GetGameTime() - stored timestamp
Remaining time before insect_swarm will be killed = CInsectSwarm::GetFlameLifetime() - Elapsed time
You can also calculate the time manually without using offsets
Below are two ways to get the remaining time
Spoiler
PHP Code:
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
float g_flTimestamp;
public void OnPluginStart()
{
RegConsoleCmd("sm_context", sm_context);
}
public Action sm_context (int client, int args)
{
float curtime = GetGameTime();
float etmanual = curtime - g_flTimestamp;
float etmemory = curtime - GetInsectTimestamp(FindEntityByClassname(MaxClients + 1, "insect_swarm"));
ReplyToCommand(client, "Manual: Elapsed time %f Remaining Time %f\n\
Memory: Elapsed time %f Remaining Time %f", etmanual, 7.0 - etmanual, etmemory, 7.0 - etmemory);
}
public void OnEntityCreated (int entity, const char[] name)
{
if ( strcmp(name, "insect_swarm") == 0 )
{
g_flTimestamp = GetGameTime();
}
}
stock float GetInsectTimestamp (int insect) { return view_as<float>(LoadFromAddress(GetEntityAddress(insect) + view_as<Address>(2952), NumberType_Int32)); }
|
This is just what I needed. Thank you so much!
|
|
|
|