View previous topic :: View next topic |
Author |
Message |
Nash

Joined: 19 Oct 2007 Posts: 95 Location: Kuala Lumpur, Malaysia
|
Posted: Sun Nov 11, 2007 11:10 pm Post subject: 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. |
|
Back to top |
|
 |
daemon

Joined: 07 Nov 2007 Posts: 62
|
Posted: Sun Nov 11, 2007 11:50 pm Post subject: |
|
|
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. _________________ -daemon [ daemonforge.org ] |
|
Back to top |
|
 |
Sajt
Joined: 16 Oct 2004 Posts: 1026
|
Posted: Mon Nov 12, 2007 4:44 am Post subject: |
|
|
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. |
|
Back to top |
|
 |
daemon

Joined: 07 Nov 2007 Posts: 62
|
Posted: Mon Nov 12, 2007 10:19 am Post subject: |
|
|
It looks like just the first 4 were used, but impulse11 also does this by default:
serverflags = serverflags * 2 + 1; _________________ -daemon [ daemonforge.org ] |
|
Back to top |
|
 |
Sajt
Joined: 16 Oct 2004 Posts: 1026
|
Posted: Mon Nov 12, 2007 12:59 pm Post subject: |
|
|
Hehe yeah, you might want to change that one so it doesn't touch beyond the first four bits... _________________ 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. |
|
Back to top |
|
 |
Nash

Joined: 19 Oct 2007 Posts: 95 Location: Kuala Lumpur, Malaysia
|
Posted: Mon Nov 12, 2007 2:20 pm Post subject: |
|
|
FRIK_FILE seems to be the most elegant solution. Thanks daemon! |
|
Back to top |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Mon Nov 12, 2007 7:46 pm Post subject: |
|
|
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.  _________________ What's a signature? |
|
Back to top |
|
 |
|