Hello,
Im working with multiple entities, I scan all of them and I work with specific entities I need.
I filter them by classname and targetname when needed but this method is not working always.
I have no problem finding "func_door" and "func_button".
But I am having problems finding "logic_relay" and "prop_dynamic".
About prop_dynamic, I solved it using:
GetEntPropString(entity, Prop_Data, "m_iName", targetname, sizeof(targetname));
PHP Code:
char classname[32], targetname[32];
int entity;
//scan all entities...
int count = GetEntityCount();
for ( entity=1; entity<=count; entity++ )
{
if ( IsValidEntity(entity) )
{
GetEntityClassname(entity, classname, sizeof(classname));
Entity_GetTargetName(entity, targetname, sizeof(targetname));
if ( strlen(targetname)==0 )
GetEntPropString(entity, Prop_Data, "m_iName", targetname, sizeof(targetname));
}
else
continue;
if ( strcmp(classname, "logic_relay")==0 )
{
PrintToServer("STEP 0/4: logic_relay OK - - - - - - - - - - - - - - - - -");
GetEntPropString(entity, Prop_Data, "m_iName", targetname, sizeof(targetname));
if ( strcmp(targetname, "elevator_bottom_relay")==0 )
{
//lock doors temporary, so they dont open automatically...
SetVariantString("OnTrigger door_elev*:Lock::1.0:-1");
AcceptEntityInput(entity, "AddOutput");
PrintToServer("STEP 1/4: elevator_bottom_relay OK - - - - - - - - - - - - - - - - -");
}
}
else if ( strcmp(classname, "func_door")==0 )
{
//open doors whenever they try to close...
SetVariantString("OnClose !self:Open::1.8:-1");
AcceptEntityInput(entity, "AddOutput");
//prepare a horde/special infected...
HookSingleEntityOutput(entity, "OnOpen", OnOpenFirstTime, true);
PrintToServer("STEP 2/4: func_door OK - - - - - - - - - - - - - - - - -");
}
//------------------------------------------------------------------------------------------------------
else if ( strcmp(classname, "func_button")==0 )
{
if ( strcmp(classname, "elevator_button")==0 )
continue;
//we need to respawn button to make it usable again...
//but we will Lock it to prevent firing extra panic events...
AcceptEntityInput(entity, "Lock");
DispatchKeyValue(entity, "wait", "-1");
DispatchSpawn(entity);
//unlock doors...
SetVariantString("OnUseLocked door_elev*:Unlock::0.0:-1");
AcceptEntityInput(entity, "AddOutput");
//open doors manually...
SetVariantString("OnUseLocked door_elev*:Open::0.3:-1");
AcceptEntityInput(entity, "AddOutput");
PrintToServer("STEP 3/4: func_button OK - - - - - - - - - - - - - - - - -");
}
//------------------------------------------------------------------------------------------------------
else if ( strcmp(classname, "prop_dynamic")==0 )
{
GetEntPropString(entity, Prop_Data, "m_iName", targetname, sizeof(targetname));
if ( strcmp(targetname, "elevator_model")==0 )
{
RemoveEntity(entity);
PrintToServer("STEP 4/4: prop_dynamic::elevator_model OK - - - - - - - - - - - - - - - - -");
}
/*else
{
PrintToServer("STEP 4/4 FAIL: TEST: %s - - - - - - - - - - - - - - - - -", test);
}*/
}
else
continue;
}
PHP Code:
stock char[] Entity_GetTargetName(int entity, char[] buffer, int size)
{
return GetEntPropString(entity, Prop_Data, "m_target", buffer, size);
}
But I am not able to get
logic_relay with this method.
I can only get it like this:
PHP Code:
entity = INVALID_ENT_REFERENCE;
while ( (entity=FindEntityByClassname(entity, "logic_relay"))!=INVALID_ENT_REFERENCE )
{
GetEntPropString(entity, Prop_Data, "m_iName", classname, sizeof(classname));
if ( strcmp(classname, "elevator_bottom_relay")==0 )
{
//lock doors temporary, so they dont open automatically...
SetVariantString("OnTrigger door_elev*:Lock::1.0:-1");
AcceptEntityInput(entity, "AddOutput");
break;
}
}
This is the only way I could find logic_relay. But I don't think it is the best way because I am scanning all entities twice. Does logic_relay have an special prop for classname and targetname??
m_iName didn't work.
NOTE: In this example,
m_iName is set for logic_relay. But if I try to find it on above example,
m_iName is never set to
elevator_bottom_relay