amxmodx icon indicating copy to clipboard operation
amxmodx copied to clipboard

more accurate cmd_target when given a full name

Open ghost opened this issue 5 years ago • 2 comments

To explain the problem i will give a 2 player example player 1 is named: "SmirnoffBG" player 2 : "SmirnoffBG's bot" when i use cmd_target(id, "SmirnoffBG", 0) it will never reach the id of smirnoffbg Here is 1.10's code:

new player = find_player("bl", arg)
if (player)
{
	if (player != find_player("blj", arg))
	{
		console_print(id, "%L", id, "MORE_CL_MATCHT");
		return 0;
	}
}

Here is my fix:

new player = find_player("bl", arg);
if (player)
{
	if (player != find_player("blj", arg) && (player = find_player("a",arg)) == 0)
	{
		console_print(id, "%L", id, "MORE_CL_MATCHT");
		return 0;
	}
}

so with (player = find_player("a",arg)) == 0 i scan if the player that is first found is the player which answers to the full string and if it is he is our guy

ghost avatar Jan 05 '20 05:01 ghost

Thanks for the fix, you are right, it doesn't make sense to not check if there's only one player with that full name before sending the message of multiple matches, this will improve the accuracy of the function. I don't get why voed dislike this.

PD: It should be added too a check for player full name with case insensitive.

rtxa avatar Apr 07 '20 19:04 rtxa

i am the OP and i came to report the issue again :D, but i found my old so i dont know how to bumb my post so i will just comment

SmirnoffBG avatar Oct 06 '23 13:10 SmirnoffBG