Hello,
I've started on some of my own mapping projects for Source, some of the functionality of these maps require SourceMod to trigger map entities, all of which is already possible to an extent.
SourceMod cannot trigger any non-networkable entities, these would be: logic_relay, logic_timer, etc...
Previously I've been using
this plugin to enable use of
ent_fire. This works perfectly, but has a few complications. (Resetting cvars, rcon access)
So here I am, sharing two things: a snippet and an example plugin.
PHP Code:
FireEntityInput(const String:strTargetname[], const String:strInput[], const String:strParameter[]="", const Float:flDelay=0.0)
{
decl String:strBuffer[255];
Format(strBuffer, sizeof(strBuffer), "OnUser1 %s:%s:%s:%f:1", strTargetname, strInput, strParameter, flDelay);
new entity = CreateEntityByName("info_target"); // Dummy entity. (Pretty sure every Source game has this.)
if(IsValidEdict(entity))
{
DispatchSpawn(entity);
ActivateEntity(entity);
SetVariantString(strBuffer);
AcceptEntityInput(entity, "AddOutput");
AcceptEntityInput(entity, "FireUser1");
CreateTimer(0.0, DeleteEdict, entity); // Remove on next frame.
return true;
}
return false;
}
public Action:DeleteEdict(Handle:timer, any:entity)
{
if(IsValidEdict(entity)) RemoveEdict(entity);
return Plugin_Stop;
}
This function works by creating a dummy entity, and making it fire any input specified. The dummy entity is quickly removed afterwards.
Specifying a classname would trigger all entities with that classname. Non-networkable entities work too!
As for the plugin:
Usage:
sm_entfire - Same functionality as
ent_fire.
Enjoy!