Getting shape name of player who enters trigger
by Nmuta Jones · in Torque Game Engine · 06/17/2009 (11:37 am) · 7 replies
I've done this before a million times but I can't remember how access the player's name of a player who enters a trigger. I've tried:
%obj.client.getShapeName();
%obj.client.name;
%obj.getShapeName();
but I just get "Your name is".
What's the syntax again for getting the shape name of a player who enters a trigger?
%obj.client.getShapeName();
%obj.client.name;
%obj.getShapeName();
but I just get "Your name is".
What's the syntax again for getting the shape name of a player who enters a trigger?
Parent::onEnterTrigger(%this,%trigger,%obj);
%myshape = %obj.client.getShapeName();
//AFX command that displays screen message
DisplayScreenMessage(%obj.client, "Your name is: "@%myshape);
}About the author
Lead Developer for MediaBreeze Multimedia
#2
Now I am trying to access the same information , but this time I'm doing it in game.cs. I need help access the players name from within the GameConnection namespace.
06/17/2009 (12:33 pm)
NEW PROBLEM Now I am trying to access the same information , but this time I'm doing it in game.cs. I need help access the players name from within the GameConnection namespace.
function GameConnection::spawnPlayer(%this, %first_spawn, %xfm)
{
// clear out old linkages between player and client
if (%this.player)
{
%this.player.client = 0;
%this.player = 0;
}
%player_name= %this.player.nameBase; // doesn't work
%player_name= %this.player.client.nameBase; // doesn't work
%player_name= %this.nameBase; // doesn't work
}
#3
after the player is created, and that works.
06/17/2009 (5:46 pm)
Well, I found that it is much easier to access the player name later in the game.cs file, in the function GameConnection::createPlayer(%this, %spawnPoint, %first_spawn)
after the player is created, and that works.
#4
i might be able to clarify a little bit here.
this is all on the server-side.
objects of type "GameConnection" are also known as clients.
a "client" is basically the network connection to a user.
it's different than the 'player' itself, because the user might be driving a car or walking an ork, or maybe they don't have a visible entity in the world at all.
client objects have a member field called "player" which is the SceneObject representing that user's presence in the world. typically it's of class "Player".
player objects also have a member field called "client" which points to the GameConnection for the user who's player this is. not all player objects have clients! AIPlayers are also of class player, but have no user, and so no client. all clients do have players tho.
so in GameConnection::spawnPlayer(%this, ...),
%this is a client, %this.player is a player, and %this.player.client is just %this again.
furthermore, player objects have a shapename, which you access through getShapeName(). gameconnections have the same name in nameBase, but as you've seen you have to access the name after it's been initialized, which can be a little tricky.
so, i guess i don't have an explicit solution for you, but hopefully cleared things up a little.
06/17/2009 (9:57 pm)
hey Nmuta -i might be able to clarify a little bit here.
this is all on the server-side.
objects of type "GameConnection" are also known as clients.
a "client" is basically the network connection to a user.
it's different than the 'player' itself, because the user might be driving a car or walking an ork, or maybe they don't have a visible entity in the world at all.
client objects have a member field called "player" which is the SceneObject representing that user's presence in the world. typically it's of class "Player".
player objects also have a member field called "client" which points to the GameConnection for the user who's player this is. not all player objects have clients! AIPlayers are also of class player, but have no user, and so no client. all clients do have players tho.
so in GameConnection::spawnPlayer(%this, ...),
%this is a client, %this.player is a player, and %this.player.client is just %this again.
furthermore, player objects have a shapename, which you access through getShapeName(). gameconnections have the same name in nameBase, but as you've seen you have to access the name after it's been initialized, which can be a little tricky.
so, i guess i don't have an explicit solution for you, but hopefully cleared things up a little.
#5
I still don't fully understand all of the namespaces within Torque, and this is a good pointer. Any place within TDN or the documentation where I can go to understand these namespaces : GameConnection, AiPlayer, DemoPlayer, etc.
I've been working with them through the years but I don't fully understand how to access functions within one namespace from another, etc.
06/18/2009 (7:46 am)
Orion, I solved the problem as you saw but your big picture explanation is extremely helpful.I still don't fully understand all of the namespaces within Torque, and this is a good pointer. Any place within TDN or the documentation where I can go to understand these namespaces : GameConnection, AiPlayer, DemoPlayer, etc.
I've been working with them through the years but I don't fully understand how to access functions within one namespace from another, etc.
#6
docs.garagegames.com/tge/official/content/documentation/Engine/Reference/inherit...
which looks like a class hierarchy for the C-side,
much of which is reflected in the script-side.
06/18/2009 (8:30 am)
hm, after some searching on google i found this:docs.garagegames.com/tge/official/content/documentation/Engine/Reference/inherit...
which looks like a class hierarchy for the C-side,
much of which is reflected in the script-side.
#7
06/18/2009 (9:29 am)
That is very helpful. Torque is huge. Thanks for the link to the diagram
Torque Owner Nmuta Jones