mirror of
https://github.com/Resxt/Plutonium-IW5-Scripts.git
synced 2025-05-09 22:14:53 +00:00
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:
parent
87486829b9
commit
64465a9cc9
@ -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");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user