function findClientByStartOfName(%name)
{
%matchCount = 0;
%numOfClients = clientGroup.getCount();
for(%count = 0; %count < %numOfClients; %count++)
{
%target = clientGroup.getObject(%count);
if(getSubStr(%target.name, 0, strLen(%name)) $= %name)
{
%matchedClient = %target;
%matchedCount++;
}
}
if(!(%matchedClient $= ""))
{
if(%matchedCount == 1)
{
return(%matchedClient);
}
}
return false;
}
Okay, so I think this does exactly what I want it to. This actually turned out to be a lot simpler than I first thought it would be, thanks for giving me direction on what to do.
But now for letting the player no what went wrong. Would it be better to have the function use %client as a parameter, so that way it can just message the player itself telling them what is wrong. Or would it be better to return numbers, so like 2 for multiple matches found and 3 for no match found. I think that would be harder because then I have to deal with it each time I call it but I don't really know.