How to get the player object?
by EricCartman · in Technical Issues · 02/02/2005 (9:42 pm) · 4 replies
Have tried the following:
%player=%client.player;
%player.dump();
how come this doesn't work? It keeps telling me "unable to find object"?
Thanks
%player=%client.player;
%player.dump();
how come this doesn't work? It keeps telling me "unable to find object"?
Thanks
#2
02/03/2005 (12:27 am)
I started the example program, and tried to type it in console.
#3
What you really want to do is to open up the console, and type
tree();
then close the console again, and browse the structures using the two windows that opened up. IIRC, the player object will be in the ClientGroup, find the object ID (a number, most likely in the 1000 range), then type:
xxxx.dump();
where xxxx is the number associated with the player data object in the ClientGroup.
02/03/2005 (6:16 am)
By definition, the % sign makes your variable a local variable. There is no %player available as a variable at the console itself.What you really want to do is to open up the console, and type
tree();
then close the console again, and browse the structures using the two windows that opened up. IIRC, the player object will be in the ClientGroup, find the object ID (a number, most likely in the 1000 range), then type:
xxxx.dump();
where xxxx is the number associated with the player data object in the ClientGroup.
#4
Everyone hits this issue at one time or another, which is needing/wanting to know the client ID. The easiest way to get this is to cheat and save it in a global.
Simply open server/scripts/game.cs and locate this code:
Now, add a global:
Simply add this code:
Yes, you could collect all the data in createPlayer() if you wanted.
Now, if you need the player data simply type:
$Game::Player.dump();
Likewise for client or camera.
[HOW]EdM|EGTGE
02/03/2005 (2:26 pm)
Eric,Everyone hits this issue at one time or another, which is needing/wanting to know the client ID. The easiest way to get this is to cheat and save it in a global.
Simply open server/scripts/game.cs and locate this code:
function GameConnection::onClientEnterGame( %clientID )
{Now, add a global:
$Game::ClientHandle = %clientID;To do the same for player, find this routine (also in game.cs):
function GameConnection::createPlayer(%this, %spawnPoint)
Simply add this code:
$Game::Player = %this.player; $Game::Camera = %this.camera;
Yes, you could collect all the data in createPlayer() if you wanted.
Now, if you need the player data simply type:
$Game::Player.dump();
Likewise for client or camera.
[HOW]EdM|EGTGE
Torque 3D Owner Stephen Zepp