View Single Post
SauerkrautKebap
New Member
Join Date: May 2021
Old 06-14-2021 , 13:59   Re: How do I get a value from an entity output?
Reply With Quote #2

Thanks to AdRiAnIlloOs help, I managed to get this code to work:

PHP Code:
public void OnPluginStart()
{
    
HookEntityOutput("mapvetopick_controller""OnSidesPicked"Entity_VetoController_OnSidesPicked);
}

public 
void Entity_VetoController_OnSidesPicked(const char[] outputint callerint activatorfloat delay)
{
    
int switchSides GetEntProp(callerProp_Data"m_OnSidesPicked");

This does not work for every entity output, tho! The maximum size of GetEntProp() is 1 cell (4 bytes), but most members of COutputVariant are 24 bytes long. If you try to use math_counter::m_OutValue for example, SourceMod is going to throw an exception. The solution is to use GetEntData() like in this example AdRiAnIlloO provided me with:
PHP Code:
#include <sdktools_entoutput>

public void OnMapStart()
{
    
HookEntityOutput("math_counter""OutValue"OnMathCounterOutValue);
}

void OnMathCounterOutValue(const char[] outputint callerint activatorfloat delay)
{
    
float value GetEntDataFloat(callerFindDataMapInfo(caller"m_OutValue"));
    
PrintToServer("OnMathCounterOutValue called. New value = %f."value);

GetEntData() performs no strict checking like GetEntProp() so it's less save to use but gets the job done.

Apparently there has been an attempt by the devs to also make it work with GetEntProp():
https://forums.alliedmods.net/showpo...5&postcount=16
But this has never made it to the stable branches.
SauerkrautKebap is offline