Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding

Reply
 
Thread Tools Display Modes
Old 09-09-2012, 02:43 AM   #1
mundizor
 
 
 
Join Date: Aug 2012
Reputation: 0
Posts: 12
Variables resetting

Hi.

I'm fairly new with the source engine and im experiencing some problems. I have high experience in c++ and I have worked with UDK so I have worked with 3D engines before. With that said I'm having som problems with sdk_gamemovement. I'm altering this file to alter the movement in game.

Code:
void CSDKGameMovement::calculateHowToMove(CBasePlayer *pBasePlayer, CMoveData *pMove)
{	
        //test is a float in global scope.

	DevMsg("Test = : %.2f \n", test);
	if(pBasePlayer->m_playerDestination.x != 0)
	{
		test = 400;
	}
		
}
The variable pBasePlayer->m_playerDestination.x is a variable in player that is sent over the network. This variable equals 0 half of the time, but since its a network var I can live with that and work around it.

To be able to work around it I need to save the correct value and work with that but it seems impossible at this moment. This is the only use of the variable test but still it prints 0 half of the time. The enly reason I see for test to becoming 0 is if the instance of this class is removed and then created again but in that case test would always equal 0 so that can't be it.

So I ask you: Why does test become 0 without me assigning it to 0?
mundizor is offline  
Reply With Quote
Old 09-09-2012, 03:15 AM   #2
Sandern
 
 
 
Join Date: Jun 2009
Reputation: 34
Posts: 101
It's a bit hard to say without seeing all the code, but I think m_playerDestination is networked incorrectly. So on the client it is always 0 and you never set test to 400 on the client.

The gamemovement code runs on both the server and client (prediction), so half of the time you are printing the test variable of the client, which you have never set.
Sandern is offline   Reply With Quote
Old 09-09-2012, 03:21 AM   #3
mundizor
 
 
 
Join Date: Aug 2012
Reputation: 0
Posts: 12
Thanks for the answer, i'm going to look into this.
mundizor is offline   Reply With Quote
Old 09-09-2012, 03:26 AM   #4
mundizor
 
 
 
Join Date: Aug 2012
Reputation: 0
Posts: 12
Yes, you were right, the client is not receiving the value properly. Now I jsut gotta find a way to fix it. But its alot easier when I know what im dealing with. Thanks again.
mundizor is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -7. The time now is 10:02 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2012, All Rights Reserved.