Game Development Community

Looking for Player ID

by David Dougher · in Torque Game Engine · 06/17/2003 (8:47 am) · 4 replies

Has anyone written a function to obtain the Player ID?

I have been trying to extract it from ServerConnection:;GameConnection for use in a dedicated client but I can't seem to get the ID of Player.

If anybody has written such a function please post it - thanks.

About the author

Owner - Pariah Games, Adjunct Professor - Bristol Community College, Mentor - Game Design - Met School Newport, Mentor - Game Design - Met School Providence


#1
06/17/2003 (9:32 am)
This funcitonality already exists. I dont know what your code looks like or if you are trying to expose this to the scripting engine but here is a small snipit:

// lets say obj is a SimObject->Player
Player *player = static_cast<Player*>(obj);

// this will get the id
S32 id = player->getId();
#2
06/17/2003 (9:57 am)
Exactly.

I am trying to get to the player object ID in the scripts - client side - so I can determine the player's position - and from that determine terrain block the player is standing on.

Server side would be relatively easy but I want a client side solution because the code has to work in the player's system when connected to a dedicated server.

If I use tree() in the console I can see that there are two instances of Player that are client side. One is located in MissionCleanup and the other is under ServerConnection -GameConnection.

I would prefer the latter, since it has the server's opinion of where the client is currently located and that will drive my positional info better.

The plan was to simply get the ID of the player and then use id.getPosition(); to retrieve the position.
#3
06/17/2003 (1:01 pm)
David,

From script you would want:

%metaPos = LocalClientConnection.getControlObject().getTerrainPos();
// %metaPos now contains somethine like "39 101"

%pos = LocalClientConnection.getControlObject().getTerrainBlock();
// %pos now contains soemthing like "39 101 0"

The first example is the position of the player on the metaGrid. The second is the position of the player on their local terrain block followed by the block number they're standing on.
#4
06/23/2003 (11:09 am)
Also, by the way, a playerID appears to be the %client that gets passed around.

- Cow