Page 1 of 1
					
				passing strings from cgame to game
				Posted: Fri Jul 29, 2011 4:29 pm
				by Xamis
				getting frustrated trying to get this to work
I have a cvar (vmCvar_t	gear ) in the config file that I can read using gear.string, from inside cg_ files, no problem there, but I need to pass that string to game files, specifically g_weapon.c and g_client.c. I am really struggling to get this to work.
I tried creating a variable in bg_ that I can use to hold the data, but when I print out the variable inside g_client.c it's value is NULL.
I have had no problems passing other types of data this way, but passing a string of characters just isn't working for me.
Any suggestions on how to accomplish this.
			 
			
					
				Re: passing strings from cgame to game
				Posted: Fri Jul 29, 2011 6:19 pm
				by ^misantropia^
				Keep in mind that the client and server may run on different machines so global variables are definitely not the way to go. Grep the source for `CG_ConfigString` and `trap_SetConfigstring`, that'll show you how to pass data between them.
			 
			
					
				Re: passing strings from cgame to game
				Posted: Mon Aug 01, 2011 1:27 pm
				by Xamis
				So `CG_ConfigString` and `trap_SetConfigstring` both appear to pass info to cgame from game, server to client . The opposite of what I need. I needed to pass info from a  cvar on the client to the server. I figured out how to do it, and it was very easy and straight forward. Look into Info_ValueForKey( ). I passed the info in the clientinfo config string.
			 
			
					
				Re: passing strings from cgame to game
				Posted: Wed Nov 14, 2012 3:53 pm
				by nexus024
				Does anyone know of another way a cvar could be passed from cgame to game without using Info_ValueForKey()?
			 
			
					
				Re: passing strings from cgame to game
				Posted: Wed Nov 14, 2012 4:38 pm
				by Eraser
				You oughta specify why the original solution is insufficient for you. Now it's kind of guessing what you need.
			 
			
					
				Re: passing strings from cgame to game
				Posted: Wed Nov 14, 2012 6:11 pm
				by nexus024
				I am trying to reverse engineer a mod in order to make mine compatible with it.  I printf what gets passed through Info_ValueForKey and that method is not being used to pass the data.  How else could the data get sent from cgame to game?
			 
			
					
				Re: passing strings from cgame to game
				Posted: Thu Nov 15, 2012 5:31 am
				by Eraser
				Info_ValueForKey doesn't send any data, it's a helper function to read data from a special kind of string that contains key/value pairs. The clue is the bit about clientinfo. That is client specific data that's transmitted to the server
			 
			
					
				Re: passing strings from cgame to game
				Posted: Thu Nov 15, 2012 2:41 pm
				by nexus024
				Yes, I have checked there to by issuing the clientinfo command, but unfortunately the data is not being stored in there.  Any other ways of transferring data between cgame and game??