Global variables - how?
Moderator: InsideQC Admins
7 posts
• Page 1 of 1
Global variables - how?
How do I create floats or custom fields that do not get reset when the map changes?
I want to do something like, a secret triggered from the previous map can only be seen on the next map. Stuff like that.
No, I don't want to use the dummy cvars because I don't want players to freely set the cvar.
I think it's possible because the player items are saved for the next map but I don't understand how it works.
Thanks in advance.
I want to do something like, a secret triggered from the previous map can only be seen on the next map. Stuff like that.
No, I don't want to use the dummy cvars because I don't want players to freely set the cvar.
I think it's possible because the player items are saved for the next map but I don't understand how it works.
Thanks in advance.
-

Nash - Posts: 95
- Joined: Fri Oct 19, 2007 5:56 pm
- Location: Kuala Lumpur, Malaysia
The way the player items and stats are saved is by setting the player's parms to those values, and each player's parms are carried over through map changes, then loaded back into the variables once the map is loaded.
So, if you wanted to use parms to carry over global values, you could probably use spawnclient() to create a fake client and use it's parm values to hold the global values you want to save.
OR
You could use FRIK_FILE to save those values to a file before the map change, and then load them back into the global variables on the next map start.
I would probably use the FRIK_FILE method if I didn't want to use up a player slot, and/or I had a LOT of global variables I wanted to carry though level changes.
You could ALSO use the serverflags variable to store values like parms, but that is already used by many things in Quake, and since there is only one of them, you are limited as to how much and what kind of information you can store in it. If all you want to save is true/false flags, then serverflags might be what you want.
So, if you wanted to use parms to carry over global values, you could probably use spawnclient() to create a fake client and use it's parm values to hold the global values you want to save.
OR
You could use FRIK_FILE to save those values to a file before the map change, and then load them back into the global variables on the next map start.
I would probably use the FRIK_FILE method if I didn't want to use up a player slot, and/or I had a LOT of global variables I wanted to carry though level changes.
You could ALSO use the serverflags variable to store values like parms, but that is already used by many things in Quake, and since there is only one of them, you are limited as to how much and what kind of information you can store in it. If all you want to save is true/false flags, then serverflags might be what you want.
-daemon [ daemonforge.org ]
-

daemon - Posts: 63
- Joined: Wed Nov 07, 2007 11:10 pm
What is serverflags all used by? I think the first four 'bits' were used for runes, but is the rest of it ever used? If not, you have 20-ish bits you can use for global boolean flags...
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
- Sajt
- Posts: 1215
- Joined: Sat Oct 16, 2004 3:39 am
It looks like just the first 4 were used, but impulse11 also does this by default:
serverflags = serverflags * 2 + 1;
serverflags = serverflags * 2 + 1;
-daemon [ daemonforge.org ]
-

daemon - Posts: 63
- Joined: Wed Nov 07, 2007 11:10 pm
I recommend that you still use one of the bits in serverflags to signify the presence of data from the previous map. Failure to do so might otherwise result in awkwardness when starting a new game. Just one flag.
yeah, only four bits of serverflags are normally used. and impulse 11 is a cheat.
yeah, only four bits of serverflags are normally used. and impulse 11 is a cheat.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest