Raised This Month: $32 Target: $400
 8% 

[SNIPPET] Fire Entity Input (ent_fire alternative)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
SoulSharD
Member
Join Date: Oct 2013
Location: United Kingdom
Old 04-11-2015 , 10:53   [SNIPPET] Fire Entity Input (ent_fire alternative)
Reply With Quote #1

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(strBuffersizeof(strBuffer), "OnUser1 %s:%s:%s:%f:1"strTargetnamestrInputstrParameterflDelay);
    
    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.0DeleteEdictentity); // Remove on next frame.
        
return true;
    }
    return 
false;
}

public 
Action:DeleteEdict(Handle:timerany: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!
Attached Files
File Type: sp Get Plugin or Get Source (sm_entfire.sp - 1077 views - 1.3 KB)
__________________

SoulSharD is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:33.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode