Game Development Community

IsNameUnique Bug

by Seth Willits · in Torque Game Builder · 05/10/2008 (6:35 pm) · 1 replies

function isNameUnique(%name)
{
   %count = ClientGroup.getCount();
   for (%i = 0; %i < %count; %i++)
   {
      %client = ClientGroup.getObject(%i);
      
      // This bit of original code does not work:
      //%test = detag(getTaggedString(%client.name));
      //if (strcmp(%name, %test) == 0)
      //   return false;

      // Simply doing this works just dandily
      if (%name $= %client.name) return false;
   }
   
   // If we get here, the name is unique.
   return true;
}

#1
05/10/2008 (7:17 pm)
And not a bug, but it's only logical that GameConnection::setPlayerName() tell the connected client what their player name really is. One way is to add commandToClient at the end of the function, and then handling the command in your game's code.

commandToClient(%client, 'SetPlayerName', %client.name);

function clientCmdSetPlayerName(%name)
{
   $pref::Player::name = %name;
   $GAME::Player::Name = $pref::Player::name;
}