Author Topic: findClientByName.  (Read 2085 times)

I understand what it itself does, but I would like to know the coding for it, since I know it's not a "core function."

Do you mean the source?
Code: [Select]
function findClientByName(%name)
{
for(%i=0;%i<ClientGroup.getCount();%i++)
{
%client = ClientGroup.getObject(%i);
if(strPos(%client.getPlayerName(),%name) > -1)
return %client;
}
return -1;
}

Do you mean the source?
Code: [Select]
function findClientByName(%name)
{
for(%i=0;%i<ClientGroup.getCount();%i++)
{
%client = ClientGroup.getObject(%i);
if(strPos(%client.getPlayerName(),%name) > -1)
return %client;
}
return -1;
}
I was thinking something like that.

Thanks

Core function? What do you mean? It comes default with the game and will be available to all add-ons, if what I think you're saying is correct.

Core function? What do you mean? It comes default with the game and will be available to all add-ons, if what I think you're saying is correct.
i mean automatically built into Torque

Code: [Select]
function findClientByName(%name)
{
for(%i=0;%i<ClientGroup.getCount();%i++)
{
%client = ClientGroup.getObject(%i);
if(strPos(%client.getPlayerName(),%name) > -1)
return %client;
}
return -1;
}

I'd suggest not making it case sensitive:

Code: [Select]
function findClientByName(%name)
{
%count = ClientGroup.getCount();

for(%i = 0; %i < %count; %i++)
{
%client = ClientGroup.getObject(%i);

if(striPos(%client.getPlayerName(),%name) != -1)
return %client;
}

return -1;
}

is it really necessary to use getPlayerName or could I just do %client.name

I've always used %client.name, that's what I'm used to using, and it always worked fine.


is it really necessary to use getPlayerName or could I just do %client.name
This is the preferred way by Badspot to get the player's name, it was in an update a while back. He said to use it instead of %Client.name.

I would use %Client.getPlayerName() instead of %Client.name just because Badspot said to and you know... he can change stuff whenever he wants...

Well, I believe setPlayerName has syntax to it. Like, is phrases the name given to clean it up. Not that it can be accessed in Blockland Retail, but getPlayerName must have it's own type of code in it.

Bet in basics, setPlayerName just did %client.name = Blah; but with fixes. So think of getPlayerName in the same way.

Well, I believe setPlayerName has syntax to it. Like, is phrases the name given to clean it up. Not that it can be accessed in Blockland Retail, but getPlayerName must have it's own type of code in it.

Bet in basics, setPlayerName just did %client.name = Blah; but with fixes. So think of getPlayerName in the same way.
Yes but Badspot approves and prefers it.

Tom

And at some point Badspot my remove acess to %client.name.

And at some point Badspot my remove acess to %client.name.
You can't remove access to a variable

You can't remove access to a variable
He might remove access to it as in, he'll no longer set it to the client's actual name. Silly.