Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

saving CVARS

| Inside3d Forums Forum Index -> QuakeC Programming

View previous topic :: View next topic
Author | Message
--- | ---
scarypajamas Joined: 26 May 2008 Posts: 5 |

Posted: Fri Jul 04, 2008 8:13 pm Post subject: saving CVARS |

I'm using CSQC to do my HUD and in game GUI. I'm using cvars to control what's up on the screen (1 = we draw it, 0 = no, etc). The problem is when I save, quit and come back later to load my level, everything that should be up on the screen isn't. My cvars, which should be 1 or higher, have dropped to 0 because there not saving to a quake .sav file.
I'm regestering my cvars with csqc and using them to control my GUI so I need them to save! So the the big question is, how do you save cvars?? I'm using the darkplaces engine if that helps.
ps: I also tried the built in scratch1-4 cvar but they don't save either.

Back to top |

frag.machine Joined: 25 Nov 2006 Posts: 728 |

Posted: Fri Jul 04, 2008 10:47 pm Post subject: |

from GlQuake src (cvar.h)

Code:
typedef struct cvar_s { char *name; char *string; qboolean archive; // set to true to cause it to be saved to vars.rc
qboolean server; // notifies players when changed
float value;
struct cvar_s *next;
} cvar_t;

So, when declaring a new cvar, do like this:

Code:
cvar_t foobar = {"foobar","1", true};

_________________
frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/

Back to top |

scarypajamas Joined: 26 May 2008 Posts: 5 |

Posted: Fri Jul 04, 2008 11:40 pm Post subject: |

Thanks frag.machine it worked!

Back to top |

Spike Joined: 05 Nov 2004 Posts: 944 Location: UK |

Posted: Sat Jul 05, 2008 5:47 am Post subject: |

Use the seta console command, presumably in the defaults.cfg file for your mod. This will cause the engine to automatically save them, as well as allow the user to change them before the client has joined a game. Modifying the engine for this is pointless.
_________________
What's a signature?

Back to top |

scarypajamas Joined: 26 May 2008 Posts: 5 |

Posted: Sat Jul 05, 2008 11:12 pm Post subject: |

I used both your suggestions Thanks for your help!

Back to top |

GiffE Joined: 08 Oct 2006 Posts: 141 Location: USA, CT |

Posted: Sun Jul 06, 2008 7:45 pm Post subject: |

Why not use AddStat in ssqc to send a player's var when it changes. add:

Code:
void(float index, float type, .float) SV_AddStatFloat = #232; void(float index, float type, .string) SV_AddStatString = #232;

to your ssqc's def's.
Then in your ssqc in worldspawn
do:

Code:
SV_AddStatFloat(33, 2, myfieldvar);

NOTE:

Code:
// Set up an auto-sent player stat. // Client's get thier own fields sent to them. Index may not be less than 32. // Type is a value equating to the ev_ values found in qcc to dictate types. Valid ones are: // 1: string (4 stats carrying a total of 16 charactures)
// 2: float (one stat, float converted to an integer for transportation)
// 8: integer (one stat, not converted to an int, so this can be used to transport floats as floats - what a unique idea!)

That should explain all the different things you pass into addstat.
First is the stat num, next is the type (types above) and lastly is the field which you wish to have sent to client.
And in CSQC:
you can do (when ever you draw/update):

Code:
getstati(33);

To get the new "stat" you just made.
Hope that helps! (and to anyone else trying to figure out csqc)
-Gif
EDIT:
oh yea, I've only tested this in DP!
_________________
http://www.giffe-bin.net/

Back to top |

FrikaC Site Admin Joined: 08 Oct 2004 Posts: 947 |

Posted: Tue Jul 08, 2008 5:19 pm Post subject: |

Central Variable Access and Retrieval System

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> QuakeC Programming | All times are GMT
Page 1 of 1

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group