Update chat_commands.gsc

Improve the "FindPlayerByName" function, the current one only finds the full name of the player and this is not practical in reality because players usually have long and difficult to write names, however the new function looks for a substring that matches the name of the player, which makes it much easier to search for the player's name as long as a unique substring is provided within the player's name.
This commit is contained in:
Chenterito 2023-10-06 16:41:20 -05:00 committed by GitHub
parent 87486829b9
commit 64465a9cc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -497,11 +497,26 @@ FindPlayerByName(name)
return self;
}
matchs = 0;
foreach (player in level.players)
{
if (ToLower(player.name) == ToLower(name))
if( isSubStr( tolower( player.name), tolower(name ) ))
{
return player;
matchs++;
}
}
wait 0.05;
if( matchs == 1)
{
foreach (player in level.players)
{
if( isSubStr( tolower( player.name), tolower(name ) ))
{
return player;
}
}
}
}
@ -739,4 +754,4 @@ DebugIsOn()
PermissionIsEnabled()
{
return GetDvarInt("cc_permission_enabled");
}
}