AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [ANY] Trigger v1.1 (https://forums.alliedmods.net/showthread.php?t=224300)

WhosAsking 08-22-2013 12:54

[ANY] Trigger v1.1
 
1 Attachment(s)
Although I have been using SourceMod and coding private plugins for some time, this is my very first public release, but I felt it to be useful enough to release at large.

The inspiration for this plugin was the "Trigger Mapentities" plugin written by HSFighter. It had been a useful device for map development and testing, not to mention the occasional prank. However, we soon learned its limitations, such as requiring the class name to be able to fire the event. It also couldn't accept input values.

This is the result of my development to create a better version. It basically mimics the function of the "ent_fire" cheat command, enabling the triggering of any and all matching entities complete with optional input, but without spoiling your session by activating cheat mode.

I only delve into Team Fortress 2, but the basic nature of this plugin should render it mod-agnostic.
No CVARs are used other than the version CVAR "sm_trigger_version".
It's as simple as loading it to enable the commands and unloading it to remove them.

The plugin provides three commands, all with ROOT flag restrictions (easy to change in the source) due to their technical or powerful nature:

  • sm_trigger <entity> [input] [value]
    This is the command as described. Just use an entity's name or * wildcard and an input and value if desired. You can target an entity number with "#<number>" or an entity in your sights with "@aim".
  • sm_findentity <entity>
    This is a debugging command I used alongside this one and uses the same entity tracking feature. It will list all entities matching your input, complete with number, actual name, and class name.
  • sm_aimentity
    (In-game only) Another debugging command based on code from a private debugging plugin I made for myself. It will identify any solid entity you are aiming at and give you information about it, allowing you to record and Trigger it later if you wish.
UPDATE: 2013/09/12 - v1.1 Released. Now supports numeric entity targets using the "#" prefix as well as the "@aim" target for targets in sights . This allows for the triggering of unnamed entities. Also added the "sm_aimentity" command to learn about an entity in your sights and greatly expanded the list of default actions.

Standard disclaimers apply. You assume all responsibility for the use of this plugin. Having said that, I sincerely hope this plugin is of use to anyone. I know it has been for myself.

Snaggle 08-22-2013 15:45

Re: [ANY] Trigger v1.0
 
A very handy plugin indeed. Useful for triggering those eastereggs!

KyleS 10-16-2013 13:46

Re: [ANY] Trigger v1.1
 
sizeof is a compile-time operator :) I see you're doing manual counting using while loops and the like which isn't required, but sizeof saves a lot of headache :P

I don't understand why you can't use FindEntityByClassname, but I'm going to assume there's a good reason for it as you're pulling in sdktools anyways.

PHP Code:

// A return of -2 means the game doesn't implement
        // this feature.
        
case -2:
        {
            
ReplyToCommand(Client"\x03[Trigger]\x01 Aiming is not implemented in this game.");
        }
        
// A return of -1 means no entity was targeted.
        
case -1:
        {
            
ReplyToCommand(Client"\x03[Trigger]\x01 No solid entity targeted.");
        } 

You may want to use your defines here ;) You may also want to pass the argument sizes in the prototype, such as
PHP Code:

TriggerEntity(const Client, const EntityString:Input[ARG_SIZE], const String:Value[ARG_SIZE], String:ClassName[ARG_SIZE]) 

sizeof avoids bugs instead of manually passing the size along.

Regardless, seems relatively sane, nice job!

WhosAsking 10-18-2013 12:32

Re: [ANY] Trigger v1.1
 
I was specifically AVOIDING using that because an entity match can match entities of DIFFERENT classes (IOW, the same name may apply to a logic_case and a logic_relay). ent_fire doesn't filter by class, neither does the base event logic system, so mine doesn't filter either. Besides, I don't think FindEntityByClassname works non non-edicts like logic_case, which was one of the problems I had with Trigger Mapentities.

The code you see for finding entities is essentially copied from SMLib, but I avoid using SMLib itself to reduce the overhead, and I can see why they used this technique. It's basically the only way to go.

As for the other code, I'll look at tweaking it.

I'll look into sizeof. My coding base is C, however, and I'd always been taught there that sizeof counts in bytes, which is why it's used in memory operations. My array is of strings and other variable-length constructs which, in my thinking, can throw off sizeof.

Oh, the -2 and -1? Those are defined returns from GetClientAimTarget(), the function I use to aim at an entity. The descriptions I use are based on the API documentation (-1 if no entity is being aimed at. -2 if the function is not supported). GetClientAimTarget is one reason I still use SDKTools.

One last thing: ClassName here is an OUTPUT, meant to report the class of a found entity for reporting (for atypical matching).

Shadowysn 12-20-2021 07:19

Re: [ANY] Trigger v1.2
 
2 Attachment(s)
Converted to new-syntax for SM 1.11, should work on SM 1.10.
Added classname-targeting to sm_trigger and sm_findentity that functions similar to ent_fire.

ZBzibing 05-27-2022 05:41

Re: [ANY] Trigger v1.1
 
This is a good thing, if you can list the execution code triggered by him, it is convenient to call in other programs

how to execute on server
Code:

sm_trigger filter_generator testactivator
[Trigger Commands] Command can only be used in game on a dedicated server.
[Trigger] Triggered input 'TestActivator' of 'filter_generator'.


All times are GMT -4. The time now is 23:58.

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