/**************************************** * dynamictargeting.inc version 18.0126.0 * Used in conjunction with dynamictargeting.smx to process complex targeting strings. * * https://forums.alliedmods.net/showthread.php?t=273779 * http://ddhoward.com/sourcemod/updater/plugins/dynamictargeting.smx * http://ddhoward.com/sourcemod/updater/scripting/dynamictargeting.sp * http://ddhoward.com/sourcemod/updater/scripting/include/dynamictargeting.inc * * * It is asked, but not required, that you call CreateDTargVersionPrinter() within * your plugin's OnPluginStart(). */ #if defined _dynamictargeting_version #endinput #endif #define _dynamictargeting_version "18.0126.0" public SharedPlugin __pl_tf2isinspawn = { name = "DynamicTargeting", file = "dynamictargeting.smx", #if defined REQUIRE_PLUGIN required = 1, #else required = 0, #endif }; #if !defined REQUIRE_PLUGIN public __pl_tf2isinspawn_SetNTVOptional() { MarkNativeAsOptional("ProcessExtendedTargetString2"); } #endif /*************************************************************************************************** Please note that the following "native" runs a simple check to see if dynamictargeting.smx is loaded before calling the real native; this ensures that an unavailable native is never called, since calling an unavailable native will result in the entire callback being aborted. However, this check is considered to be expensive. If you will be using the native repeatedly and rapidly (such as in OnGameFrame, OnPlayerRunCmd, etc.), you may want to bypass the check. You can do so by simply adding a '2' to the end of the native name. ProcessExtendedTargetString() becomes ProcessExtendedTargetString2() Before manually calling the '2' native, you must do your own checking to see if the plugin is loaded. This can be done by using OnAllPluginsLoaded()+LibraryExists(), OnLibraryAdded(), and OnLibraryRemoved() with the library name "DynamicTargeting", and storing the result in a bool variable. Check that the variable is true before manually calling the '2' native!! ***************************************************************************************************/ native int ProcessExtendedTargetString2(const char[] pattern, int admin, int[] targets, int max_targets, int filter_flags); /** * Returns whether or not a given player is in their team's spawn room. * * @param pattern Pattern to find clients against. * @param admin Admin performing the action, or 0 if the server. * @param targets Array to hold targets. * @param max_targets Maximum size of the targets array. * @param filter_flags Filter flags. * @return Number of targets found */ stock int ProcessExtendedTargetString(const char[] pattern, int admin, int[] targets, int max_targets, int filter_flags) { CreateDTargVersionPrinter(); if (GetFeatureStatus(FeatureType_Native, "ProcessExtendedTargetString2") == FeatureStatus_Available) return ProcessExtendedTargetString2(pattern, admin, targets, max_targets, filter_flags); else return false; } /**************************************************************************************************** OTHER *****************************************************************************************************/ stock void CreateDTargVersionPrinter() { static bool dtargListenerCreated; if (!dtargListenerCreated) { AddCommandListener(dynamictargeting_include_versions, "dynamictargeting_include_versions"); dtargListenerCreated = true; } } //command listener which prints information to the chat, ALL plugins with this include will respond public Action dynamictargeting_include_versions(int client, const char[] cmdname, int Args) { if (CheckCommandAccess(client, "dynamictargeting_include_versions", ADMFLAG_ROOT, true)) { char pluginFilename[PLATFORM_MAX_PATH]; GetPluginFilename(INVALID_HANDLE, pluginFilename, sizeof(pluginFilename)); char pluginName[64]; if (GetPluginInfo(INVALID_HANDLE, PlInfo_Name, pluginName, sizeof(pluginName))) { Format(pluginName, sizeof(pluginName), "%s%s", pluginName, " - "); } char pluginVersion[32]; if (!GetPluginInfo(INVALID_HANDLE, PlInfo_Version, pluginVersion, sizeof(pluginVersion))) { Format(pluginVersion, sizeof(pluginVersion), "UNKNOWN"); } ReplyToCommand(client, "%s - %s%s v. %s", _dynamictargeting_version, pluginName, pluginFilename, pluginVersion); } return Plugin_Continue; }