I didn't like the behaviour of the stock SM function
FindTarget so I made this instead. Issue with FindTarget is that when you type a name and there are multiple matches it does pretty much nothing (other than an error).
This include file defines a stock function SelectTarget that works similar to FindTarget, but opens a menu to the client with all the possible matches if there are more than 1.
Best way to explain this is through an example:
PHP Code:
#include <sourcemod>
#include <menu_targeting>
public void OnPluginStart()
{
RegConsoleCmd( "sm_selecttarget", Command_SelectTarget );
}
public Action Command_SelectTarget( int client, int args )
{
char target[MAX_NAME_LENGTH];
GetCmdArgString( target, sizeof(target) );
// stock bool SelectTarget( int client, const char[] targetname, MenuTargetingCB cb )
if( !SelectTarget( client, target, PrintName ) )
{
ReplyToCommand( client, "[SM] No targets found ..." );
}
return Plugin_Handled;
}
public void PrintName( int client, int target )
{
PrintToChat( target, "[SM] I wish lambdas existed in SourcePawn :(" );
}
If there were 3 players on the server named "Ta", "Tac" and "Taco" and the user input was "Ta", then a menu shows up to the client with those 3 possible matches and the callback is called for whichever is chosen.
If the user input was instead "Taco", there is only 1 match and the callback is called immediately.