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.
passing strings from cgame to game
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
Re: passing strings from cgame to game
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
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
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
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
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
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
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??