Hi guys need help on code..
by Johnny Picciafuochi · in Torque 3D Professional · 11/09/2009 (5:00 am) · 8 replies
I almost solved many of my "problems" as script and some code, so thanks for all the help!
Now i still need to find a way to know, by script or c++, the correct position of the main char.
Or (and this it will be better) take the control of the main character object, so with this i can do almost everything i need.
I searched in the whole code of c++ but i didn't find where the player class is created (i found the player.cpp, i don't find where is a variable Player..).
I hope someone could help me with this, i truly need it!
Thanks, and sorry for my bad english!
Johnny
Now i still need to find a way to know, by script or c++, the correct position of the main char.
Or (and this it will be better) take the control of the main character object, so with this i can do almost everything i need.
I searched in the whole code of c++ but i didn't find where the player class is created (i found the player.cpp, i don't find where is a variable Player..).
I hope someone could help me with this, i truly need it!
Thanks, and sorry for my bad english!
Johnny
#2
It's global? i mean did i need to include something else?
I come from basic so i am having some little problem with gloabl, private and public ;)
Thanks for your fast reply man!!
11/09/2009 (5:21 am)
Really???It's global? i mean did i need to include something else?
I come from basic so i am having some little problem with gloabl, private and public ;)
Thanks for your fast reply man!!
#3
Goal: Where is the player in game
Things we need to know.
Is this multiplayer or singleplayer?
if its multiplayer then the group assigned to the players is called clientGroup
if it is singleplayer then its LocalConnection or ClientGroup
Since clientgroup works for both lets use it for my example.
Here is some simple code
11/09/2009 (7:21 am)
Johnny, What Bryce means to say if I am going to elaborate. Lets do this by simply talking about the script code. We want to figure out where the player is.Goal: Where is the player in game
Things we need to know.
Is this multiplayer or singleplayer?
if its multiplayer then the group assigned to the players is called clientGroup
if it is singleplayer then its LocalConnection or ClientGroup
Since clientgroup works for both lets use it for my example.
Here is some simple code
//This function has to reside in your server Scripts folder since only the server really knows who's who.
function serverCmdGiveMeMyPlayer(%client)
{
%myPlayersPosition = %client.player.getPosition();
commandToClient(%client, 'GiveMeMyPlayer', %myPlayersPosition);
}
//These are functions that have to reside in your client side Scripts folder since you want to inform the server you want an ID and you want the client to process the request in some fasion.
function clientCmdRequestClientID()
{
commandToServer('GiveMeMyPlayer');
}
function clientCmdGiveMeMyPlayer(%client, %myPlayersPosition)
{
echo("The Client ID on the server is" SPC %client SPC "and its position is" SPC %myPlayersPosition);
}
bindMap.bind(keyboard, "alt m", "clientCmdRequestClientID"); //this would bind the alt m to send you that information in console via an echo message.
#4
What i really need is the position of the player on c++ so i can take this infos from script and pass it back to c++.
I need it only in singleplayer, so this is fine!
Thanks man you are awesome!
Johnny.
11/09/2009 (8:17 am)
So this should be ok.What i really need is the position of the player on c++ so i can take this infos from script and pass it back to c++.
I need it only in singleplayer, so this is fine!
Thanks man you are awesome!
Johnny.
#5
But, what you are really trying to do? Do you need the player position for a gui control or what else?
Client side, well, it should be ok also server side, you can get your player instance variable in this way, from c++
11/09/2009 (9:15 am)
In c++, your player is an instance of the Player class, and one of its parent's method is getTransform, so you can get the whole transform.But, what you are really trying to do? Do you need the player position for a gui control or what else?
Client side, well, it should be ok also server side, you can get your player instance variable in this way, from c++
GameConnection* conn = GameConnection::getConnectionToServer(); Player* myPlayer= dynamic_cast<Player*>(conn->getControlObject());you can see this kind of code in several gui control that needs to access some of the player's variables.
#6
Is exactly what i was searching for.. i try
Player* myPlayer= dynamic_cast<Player*>(conn->getControlObject());
But i received some errors.. probably becasue i didn't use gameconnection!!
Anyway i trying to complete my floodfill way that use the player controller to create a navmesh.. I need to admit c++ i TRULY different from basic!
Davide sei italiano??
Grazie and thanks!
Johnny!
11/09/2009 (10:25 am)
That's nice!Is exactly what i was searching for.. i try
Player* myPlayer= dynamic_cast<Player*>(conn->getControlObject());
But i received some errors.. probably becasue i didn't use gameconnection!!
Anyway i trying to complete my floodfill way that use the player controller to create a navmesh.. I need to admit c++ i TRULY different from basic!
Davide sei italiano??
Grazie and thanks!
Johnny!
#7
I included the GameConnection.h from my cpp file, i did what davide said but i receive a "strange" error (at least for me..)
Something like " re-definition type 'class' " (not sure is in italian), so simply i don't understand what it mean..
I try to copy this from other code but i don't see any difference.
11/16/2009 (6:33 am)
Sorry guys.. other problem.I included the GameConnection.h from my cpp file, i did what davide said but i receive a "strange" error (at least for me..)
Something like " re-definition type 'class' " (not sure is in italian), so simply i don't understand what it mean..
I try to copy this from other code but i don't see any difference.
#8
11/16/2009 (6:35 am)
Ok sorry found it in google.. i am a bad programmer!
Torque Owner BryceSquared
Default Studio Name