saving CVARS
Moderator: InsideQC Admins
7 posts
• Page 1 of 1
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.
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.
- scarypajamas
- Posts: 5
- Joined: Mon May 26, 2008 7:15 pm
from GlQuake src (cvar.h)
So, when declaring a new cvar, do like this:
- Code: Select all
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: Select all
cvar_t foobar = {"foobar","1", true};
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
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.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Why not use AddStat in ssqc to send a player's var when it changes.
add:
to your ssqc's def's.
Then in your ssqc in worldspawn
do:
NOTE:
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):
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!
add:
- Code: Select all
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: Select all
SV_AddStatFloat(33, 2, myfieldvar);
NOTE:
- Code: Select all
// 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: Select all
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!
- GiffE
- Posts: 170
- Joined: Sun Oct 08, 2006 3:39 pm
- Location: USA, CT
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest