|
| 1 | +# EntityOutputInfo |
| 2 | + |
| 3 | +A [SourceMod](https://www.sourcemod.net/) plugin that exposes a native API for inspecting and manipulating [Source Engine entity outputs](https://developer.valvesoftware.com/wiki/Outputs) at runtime. |
| 4 | + |
| 5 | +Entity outputs are the connections wired between entities in a map (e.g. `OnTrigger → func_door → Open`). This plugin reads the engine's internal datamap structures directly, giving other plugins full read/write access to those connections without relying on I/O hooks. |
| 6 | + |
| 7 | +**Plugin info** |
| 8 | +| Field | Value | |
| 9 | +|-------|-------| |
| 10 | +| Name | Entity Output Info | |
| 11 | +| Authors | Botox, Addie, Dolly, .Rushaway | |
| 12 | +| SourceMod version | 1.12+ | |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## Installation |
| 17 | + |
| 18 | +> [!IMPORTANT] |
| 19 | +> Only supported on 32 bits for now (Windows/Linux) |
| 20 | +
|
| 21 | +1. Download the latest compiled `.smx` from the [Releases](../../releases) page. |
| 22 | +2. Place `EntityOutputInfo.smx` in `addons/sourcemod/plugins/`. |
| 23 | +3. Restart the server or use `sm plugins load EntityOutputInfo`. |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## Usage (for plugin developers) |
| 28 | + |
| 29 | +Add the include to your plugin and declare the dependency: |
| 30 | + |
| 31 | +```sourcepawn |
| 32 | +#include <EntityOutputInfo> |
| 33 | +
|
| 34 | +public void OnPluginStart() |
| 35 | +{ |
| 36 | + // Example: print all output actions for "OnTrigger" on entity 100 |
| 37 | + int count = GetOutputCount(100, "OnTrigger"); |
| 38 | + for (int i = 0; i < count; i++) |
| 39 | + { |
| 40 | + char formatted[512]; |
| 41 | + GetOutputFormatted(100, "OnTrigger", i, formatted, sizeof(formatted)); |
| 42 | + PrintToServer(" [%d] %s", i, formatted); |
| 43 | + } |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +To make the dependency optional, compile with `#undef REQUIRE_PLUGIN` before including, or omit the define entirely — the include handles `MarkNativeAsOptional` automatically. |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +## API Reference |
| 52 | + |
| 53 | +All natives are declared in `addons/sourcemod/scripting/include/EntityOutputInfo.inc`. |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +### `GetOutputCount` |
| 58 | + |
| 59 | +Returns the number of actions registered for the given output. |
| 60 | + |
| 61 | +```sourcepawn |
| 62 | +native int GetOutputCount(int entity, const char[] output); |
| 63 | +``` |
| 64 | + |
| 65 | +| Parameter | Type | Description | |
| 66 | +|-----------|------|-------------| |
| 67 | +| `entity` | `int` | Entity index | |
| 68 | +| `output` | `const char[]` | Output property name (e.g. `"OnTrigger"`) | |
| 69 | + |
| 70 | +**Returns:** Number of actions, or `0` if the output does not exist. |
| 71 | + |
| 72 | +--- |
| 73 | + |
| 74 | +### `GetOutputTarget` |
| 75 | + |
| 76 | +Retrieves the target name of an output action at the given index. |
| 77 | + |
| 78 | +```sourcepawn |
| 79 | +native int GetOutputTarget(int entity, const char[] output, int index, char[] target, int maxlen); |
| 80 | +``` |
| 81 | + |
| 82 | +| Parameter | Type | Description | |
| 83 | +|-----------|------|-------------| |
| 84 | +| `entity` | `int` | Entity index | |
| 85 | +| `output` | `const char[]` | Output property name | |
| 86 | +| `index` | `int` | Action index (use `FindOutput` to locate a specific action) | |
| 87 | +| `target` | `char[]` | Buffer to store the target name | |
| 88 | +| `maxlen` | `int` | Maximum length of the buffer | |
| 89 | + |
| 90 | +**Returns:** Number of bytes written to the buffer. |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | +### `GetOutputTargetInput` |
| 95 | + |
| 96 | +Retrieves the target input of an output action at the given index. |
| 97 | + |
| 98 | +```sourcepawn |
| 99 | +native int GetOutputTargetInput(int entity, const char[] output, int index, char[] targetInput, int maxlen); |
| 100 | +``` |
| 101 | + |
| 102 | +| Parameter | Type | Description | |
| 103 | +|-----------|------|-------------| |
| 104 | +| `entity` | `int` | Entity index | |
| 105 | +| `output` | `const char[]` | Output property name | |
| 106 | +| `index` | `int` | Action index | |
| 107 | +| `targetInput` | `char[]` | Buffer to store the target input | |
| 108 | +| `maxlen` | `int` | Maximum length of the buffer | |
| 109 | + |
| 110 | +**Returns:** Number of bytes written to the buffer. |
| 111 | + |
| 112 | +--- |
| 113 | + |
| 114 | +### `GetOutputParameter` |
| 115 | + |
| 116 | +Retrieves the parameter of an output action at the given index. |
| 117 | + |
| 118 | +```sourcepawn |
| 119 | +native int GetOutputParameter(int entity, const char[] output, int index, char[] parameter, int maxlen); |
| 120 | +``` |
| 121 | + |
| 122 | +| Parameter | Type | Description | |
| 123 | +|-----------|------|-------------| |
| 124 | +| `entity` | `int` | Entity index | |
| 125 | +| `output` | `const char[]` | Output property name | |
| 126 | +| `index` | `int` | Action index | |
| 127 | +| `parameter` | `char[]` | Buffer to store the parameter | |
| 128 | +| `maxlen` | `int` | Maximum length of the buffer | |
| 129 | + |
| 130 | +**Returns:** Number of bytes written to the buffer. |
| 131 | + |
| 132 | +--- |
| 133 | + |
| 134 | +### `GetOutputDelay` |
| 135 | + |
| 136 | +Retrieves the delay of an output action at the given index. |
| 137 | + |
| 138 | +```sourcepawn |
| 139 | +native float GetOutputDelay(int entity, const char[] output, int index); |
| 140 | +``` |
| 141 | + |
| 142 | +| Parameter | Type | Description | |
| 143 | +|-----------|------|-------------| |
| 144 | +| `entity` | `int` | Entity index | |
| 145 | +| `output` | `const char[]` | Output property name | |
| 146 | +| `index` | `int` | Action index | |
| 147 | + |
| 148 | +**Returns:** Delay in seconds, or `-1.0` if the output does not exist. |
| 149 | + |
| 150 | +--- |
| 151 | + |
| 152 | +### `GetOutputRefires` |
| 153 | + |
| 154 | +Retrieves the refire count of an output action at the given index. |
| 155 | + |
| 156 | +```sourcepawn |
| 157 | +native int GetOutputRefires(int entity, const char[] output, int index); |
| 158 | +``` |
| 159 | + |
| 160 | +| Parameter | Type | Description | |
| 161 | +|-----------|------|-------------| |
| 162 | +| `entity` | `int` | Entity index | |
| 163 | +| `output` | `const char[]` | Output property name | |
| 164 | +| `index` | `int` | Action index | |
| 165 | + |
| 166 | +**Returns:** Number of times the action will fire (`-1` = infinite), or `0` on failure. |
| 167 | + |
| 168 | +--- |
| 169 | + |
| 170 | +### `GetOutputFormatted` |
| 171 | + |
| 172 | +Retrieves a formatted string representation of an output action at the given index. |
| 173 | + |
| 174 | +Format: `"target,targetInput,parameter,delay,timesToFire"` |
| 175 | + |
| 176 | +```sourcepawn |
| 177 | +native int GetOutputFormatted(int entity, const char[] output, int index, char[] formatted, int maxlen); |
| 178 | +``` |
| 179 | + |
| 180 | +| Parameter | Type | Description | |
| 181 | +|-----------|------|-------------| |
| 182 | +| `entity` | `int` | Entity index | |
| 183 | +| `output` | `const char[]` | Output property name | |
| 184 | +| `index` | `int` | Action index | |
| 185 | +| `formatted` | `char[]` | Buffer to store the formatted string | |
| 186 | +| `maxlen` | `int` | Maximum length of the buffer | |
| 187 | + |
| 188 | +**Returns:** Number of bytes written to the buffer. |
| 189 | + |
| 190 | +--- |
| 191 | + |
| 192 | +### `GetOutputValue` |
| 193 | + |
| 194 | +Retrieves the integer value stored in the given output. Throws a native error if the output value type is not an integer. |
| 195 | + |
| 196 | +```sourcepawn |
| 197 | +native int GetOutputValue(int entity, const char[] output); |
| 198 | +``` |
| 199 | + |
| 200 | +| Parameter | Type | Description | |
| 201 | +|-----------|------|-------------| |
| 202 | +| `entity` | `int` | Entity index | |
| 203 | +| `output` | `const char[]` | Output property name | |
| 204 | + |
| 205 | +**Returns:** Integer value of the output. |
| 206 | + |
| 207 | +--- |
| 208 | + |
| 209 | +### `GetOutputValueFloat` |
| 210 | + |
| 211 | +Retrieves the float value stored in the given output. Throws a native error if the output value type is not a float. |
| 212 | + |
| 213 | +```sourcepawn |
| 214 | +native float GetOutputValueFloat(int entity, const char[] output); |
| 215 | +``` |
| 216 | + |
| 217 | +| Parameter | Type | Description | |
| 218 | +|-----------|------|-------------| |
| 219 | +| `entity` | `int` | Entity index | |
| 220 | +| `output` | `const char[]` | Output property name | |
| 221 | + |
| 222 | +**Returns:** Float value of the output. |
| 223 | + |
| 224 | +--- |
| 225 | + |
| 226 | +### `GetOutputValueString` |
| 227 | + |
| 228 | +Retrieves the string value stored in the given output. Throws a native error if the output value type is not a string. |
| 229 | + |
| 230 | +```sourcepawn |
| 231 | +native int GetOutputValueString(int entity, const char[] output, char[] buffer, int maxlen); |
| 232 | +``` |
| 233 | + |
| 234 | +| Parameter | Type | Description | |
| 235 | +|-----------|------|-------------| |
| 236 | +| `entity` | `int` | Entity index | |
| 237 | +| `output` | `const char[]` | Output property name | |
| 238 | +| `buffer` | `char[]` | Buffer to store the string value | |
| 239 | +| `maxlen` | `int` | Maximum length of the buffer | |
| 240 | + |
| 241 | +**Returns:** Number of bytes written to the buffer. |
| 242 | + |
| 243 | +--- |
| 244 | + |
| 245 | +### `GetOutputValueVector` |
| 246 | + |
| 247 | +Retrieves the vector value stored in the given output. Throws a native error if the output value type is not a vector. |
| 248 | + |
| 249 | +```sourcepawn |
| 250 | +native bool GetOutputValueVector(int entity, const char[] output, float vec[3]); |
| 251 | +``` |
| 252 | + |
| 253 | +| Parameter | Type | Description | |
| 254 | +|-----------|------|-------------| |
| 255 | +| `entity` | `int` | Entity index | |
| 256 | +| `output` | `const char[]` | Output property name | |
| 257 | +| `vec` | `float[3]` | Float array of size 3 to store the vector | |
| 258 | + |
| 259 | +**Returns:** `true` on success, `false` otherwise. |
| 260 | + |
| 261 | +--- |
| 262 | + |
| 263 | +### `FindOutput` |
| 264 | + |
| 265 | +Searches for an output action matching the given criteria, starting from `startIndex`. Pass `NULL_STRING` or default values to ignore a specific field. |
| 266 | + |
| 267 | +```sourcepawn |
| 268 | +native int FindOutput(int entity, const char[] output, int startIndex, |
| 269 | + const char[] target = NULL_STRING, |
| 270 | + const char[] targetInput = NULL_STRING, |
| 271 | + const char[] parameter = NULL_STRING, |
| 272 | + float delay = -1.0, |
| 273 | + int timesToFire = 0); |
| 274 | +``` |
| 275 | + |
| 276 | +| Parameter | Type | Description | |
| 277 | +|-----------|------|-------------| |
| 278 | +| `entity` | `int` | Entity index | |
| 279 | +| `output` | `const char[]` | Output property name | |
| 280 | +| `startIndex` | `int` | Index to start searching from | |
| 281 | +| `target` | `const char[]` | Target name to match, or `NULL_STRING` to ignore | |
| 282 | +| `targetInput` | `const char[]` | Target input to match, or `NULL_STRING` to ignore | |
| 283 | +| `parameter` | `const char[]` | Parameter to match, or `NULL_STRING` to ignore | |
| 284 | +| `delay` | `float` | Delay value to match, or `-1.0` to ignore | |
| 285 | +| `timesToFire` | `int` | Refire count to match, or `0` to ignore | |
| 286 | + |
| 287 | +**Returns:** Index of the matching action, or `-1` if not found. |
| 288 | + |
| 289 | +--- |
| 290 | + |
| 291 | +### `DeleteOutput` |
| 292 | + |
| 293 | +Deletes the output action at the given index. |
| 294 | + |
| 295 | +```sourcepawn |
| 296 | +native bool DeleteOutput(int entity, const char[] output, int index); |
| 297 | +``` |
| 298 | + |
| 299 | +| Parameter | Type | Description | |
| 300 | +|-----------|------|-------------| |
| 301 | +| `entity` | `int` | Entity index | |
| 302 | +| `output` | `const char[]` | Output property name | |
| 303 | +| `index` | `int` | Action index (use `FindOutput` to locate a specific action) | |
| 304 | + |
| 305 | +**Returns:** `true` on success, `false` otherwise. |
| 306 | + |
| 307 | +--- |
| 308 | + |
| 309 | +### `DeleteAllOutputs` |
| 310 | + |
| 311 | +Deletes all actions registered for the given output. |
| 312 | + |
| 313 | +```sourcepawn |
| 314 | +native int DeleteAllOutputs(int entity, const char[] output); |
| 315 | +``` |
| 316 | + |
| 317 | +| Parameter | Type | Description | |
| 318 | +|-----------|------|-------------| |
| 319 | +| `entity` | `int` | Entity index | |
| 320 | +| `output` | `const char[]` | Output property name | |
| 321 | + |
| 322 | +**Returns:** Number of actions deleted. |
| 323 | + |
| 324 | +--- |
| 325 | + |
| 326 | +### `GetOutputNames` |
| 327 | + |
| 328 | +Retrieves the name of an output at the given index by iterating the entity's datamap. |
| 329 | + |
| 330 | +```sourcepawn |
| 331 | +native int GetOutputNames(int entity, int index, char[] output, int maxlen); |
| 332 | +``` |
| 333 | + |
| 334 | +| Parameter | Type | Description | |
| 335 | +|-----------|------|-------------| |
| 336 | +| `entity` | `int` | Entity index | |
| 337 | +| `index` | `int` | Output index in the datamap | |
| 338 | +| `output` | `char[]` | Buffer to store the output name | |
| 339 | +| `maxlen` | `int` | Maximum length of the buffer | |
| 340 | + |
| 341 | +**Returns:** Number of bytes written to the buffer. |
| 342 | + |
| 343 | +## License |
| 344 | + |
| 345 | +See [LICENSE](LICENSE) for details. |
0 commit comments