|
|
#1 |
![]() Join Date: Feb 2012
Reputation: 4
Posts: 81
|
Accessing a Vector generated inside a Con_command
Hey all,
Was wondering if someone could help me out here... I've got a CON_COMMAND inside of Player.cpp, it takes a vector that is passed from the client... Here's the code I have: Code:
CON_COMMAND(MyCommand, "Retrieval of client commands...")
{
Vector tempAng;
tempAng.x = atof(args.Arg(1));
tempAng.y = atof(args.Arg(2));
tempAng.z = atof(args.Arg(3));
return;
};
Could anyone give me a simple example of how to do this? I really appreciate the help! Thanks, C Last edited by ChadReitsma: 05-03-2012 at 01:35 AM. |
|
|
|
|
|
#2 |
![]() Join Date: Jan 2011
Reputation: 1
Posts: 111
|
Without knowing what the rest of the code looks like: here's the simplest answer:
Code:
Vector g_vecTempAng;
CON_COMMAND(MyCommand, "Retrieval of client commands...")
{
g_vecTempAng.x = atof(args.Arg(1));
g_vecTempAng.y = atof(args.Arg(2));
g_vecTempAng.z = atof(args.Arg(3));
};
Code:
extern Vector g_vecTempAng; Note that using global variables in this way is considered very bad practice, and if you have the ability to access this instance of the player class from your "other file", you should instead make vecTempAng a member variable (put it in the .h file). |
|
|
|
|
|
#3 |
![]() Join Date: Feb 2012
Reputation: 4
Posts: 81
|
Awesome, thank-you Mad!
I'll try it out right now. Edited: Couldn't get it to Build on the Client side because it says: :: unresolved external symbol "class Vector g_vecTempAng" I guess I'll have to figure out a better way, I'm trying access that variable inside of a SharedFile, so it builds fine in the Server Solution (because we declared it in player.cpp), but when I try to Build the Client Solution it can't find that variable... is there a way to make this work? Last edited by ChadReitsma: 05-02-2012 at 03:41 PM. |
|
|
|
|
|
#4 |
![]() Join Date: Feb 2012
Reputation: 4
Posts: 81
|
Ok, I changed the name of it, and added it to Player.h like this:
Code:
Vector g_vecFiringAng; Code:
CBasePlayer *pPlayerTemp;
CON_COMMAND(MyCommand, "Retrieval of client commands...")
{
pPlayerTemp->g_vecFiringAng.x = atof(args.Arg(1));
pPlayerTemp->g_vecFiringAng.y = atof(args.Arg(2));
pPlayerTemp->g_vecFiringAng.z = atof(args.Arg(3));
};
NOW, I get this ♥♥♥♥ing error inside of Weapon_machinegun when I try to access it! :: error C2039: 'g_vecFiringAng' : is not a member of 'C_BasePlayer' WTF?!
|
|
|
|
|
|
#5 |
![]() Join Date: Feb 2012
Reputation: 4
Posts: 81
|
The way that this engine handles client/server communication is truly mind boggling, how can I simply tell the server to use a new firing angle which is defined in that con_command? Like ♥♥♥♥...
It's like the weapon file looks client side for the angles, but the server uses something else?? ... guhhhhhhh |
|
|
|
|
|
#6 |
![]() Join Date: Feb 2012
Reputation: 4
Posts: 81
|
[Solved]
YESSSSSSSSSSSSSSSSSS... FINALLY!!!
Thank you to everyone who helped me, I will post the solution in my other thread here! : http://forums.steampowered.com/forum....php?t=2558215 |
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|