Game Development Community

Object / Client Number Question

by Chris Fitzgerald · in Torque Game Engine · 09/30/2007 (4:53 pm) · 5 replies

I had always assumed that the client number (server side) was the same as the object number. I've noticed that this (may not) be true.

Let's say that the client number is 3456. In the console, I can do the following from the server console (Using a hard server/client seperation):

echo(3456.player.getShapeName());

Say this returns "Bob".

Now, say I do the following from script

%radius = 25;
%coordinates = %client.player.getPosition();
InitContainerRadiusSearch(%coordinates, %radius, $TypeMasks::PlayerObjectType);
while ((%targetObject = containerSearchNext()) != 0) {
error("Objects in Radius" SPC %targetObject );
}

This will print:
"Objects in Radius 3461"

Then I can do:

echo(3461.getShapeName());

And this will return "Bob." So, different numbers here.

So, are there two different ID's that can be used here for each player? Is the client ID different than the object ID? What's going on here!?

#1
09/30/2007 (4:56 pm)
> So, are there two different ID's that can be used here for each player? Is the client ID different than the object ID?

yes; look up "Ghosting" in tdn.
#2
09/30/2007 (5:14 pm)
I understand the ghosting process (well, not so much, apparently), but I thought that %client was a server-side variable (global pointer) that is used to key/create the player object. I understand that ghosted objects on the client have a different number, but my assumption was, again, that the server used the %client id only.

Thanks for the heads up.
#3
09/30/2007 (5:18 pm)
I think if you look back up at what you posted, you aren't actually confused--you are just trying to compare two different things (ok, so maybe that is confused!)

Your first check is taking 3456.player.getShapeName(): 3456 is the objectID of the client object, 3456.player is an object ID of the player assigned to that client object.

In your second check, you are simply going right to 3461.getShapeName(), which is calling getShapeName() on your player object--same as above.

If you do the following:

echo("Player Object is" SPC 3456.player );

I'm pretty sure you'll see it report 3461.
#4
09/30/2007 (5:20 pm)
Oh i see !
sorry.

the %client variable is an object of type GameConnection - what it really represents is a network connection from the server to a client machine. Even in single-player mode, a fake network connection is created. %client.player is an object of type Player - it's the avatar which belongs to that network connection. AIPlayers for example, don't have clients associated with them, but they're still a subclass of Player.

Do %client.dump() and %client.player.dump() for an idea of the methods available on each.

The server operates on both %client and %client.player.
#5
09/30/2007 (5:32 pm)
Great, thank you both. As object names and IDs are pivitol to my project, I was a bit alarmed when two numbers popped up. But, both your explainations helped. As long as I'm pointing to the same object, I'm happy :D