Alright, this is weirding me out. I've never used this, but I've wanted a RPG-system that carries between games, and I wanted to use these for that purpose. (purely for single player purposes)
The idea is simple, right? SetCVar to save the experience/level of the user, and GetCVar when the player starts a new game to set his xp/level to what it was.
However, the 2 commands don't behave.
This is my CVARINFO:
user int SFPlayerXP;
user int SFPlayerLevel;
I use SetCVar like this:
SetCVar("SFPlayerXP", "exp");
Where as "exp" is an int based on the player's XP. However, despite "exp" being 1, it saves itself in the ini as SFPlayerXP=2146435081. Why?
The core of the problem, though, is GetCVar. It does not work. I've tried the following:
int sfcvarplayerxp = GetCVar ("SFPlayerXP");
And
GiveInventory ("SFPlayerXP", (GetCVar ("SFPlayerXP")));
Either way, the console will tell me:
ACS: I don't know what SFPlayerXP is.
Thus I'm unable to do anything.
Ugh. How do these things work? What am I missing?
SetCVar/GetCVar refuse to work (with custom cvars)
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Re: SetCVar/GetCVar refuse to work (with custom cvars)
What does your CVARINFO look like?
Re: SetCVar/GetCVar refuse to work (with custom cvars)
Sorry, my post is a bit of a mess but it is there:
SFJake wrote: user int SFPlayerXP;
user int SFPlayerLevel;
Re: SetCVar/GetCVar refuse to work (with custom cvars)
I didn't see it, sorry.
What stands out for me is this:
You quoted "exp" - why? That makes it a string and that is inherently incompatible with Int CVars.
But I don't know if that's what's wrong here, unless the error message is misleading.
What stands out for me is this:
Code: Select all
SetCVar("SFPlayerXP", "exp");
But I don't know if that's what's wrong here, unless the error message is misleading.
Re: SetCVar/GetCVar refuse to work (with custom cvars)
Yeah, I feel insanely stupid right now, happens sometimes when I tunnel vision into something.
It was what you said for SetCVar, simple syntax error, but the GetCVar didn't work because I didn't use the right inventory item name in the next lines in the script, I used the names of the CVars. Since I was seeing them as an error, I thought it was the cvar and just never checked the inventory names. (until now)
I knew it, though. Its always a dumb mistake that brings me to a forum asking for scripting/coding help. Thanks for trying to help!
It was what you said for SetCVar, simple syntax error, but the GetCVar didn't work because I didn't use the right inventory item name in the next lines in the script, I used the names of the CVars. Since I was seeing them as an error, I thought it was the cvar and just never checked the inventory names. (until now)
I knew it, though. Its always a dumb mistake that brings me to a forum asking for scripting/coding help. Thanks for trying to help!
Re: SetCVar/GetCVar refuse to work (with custom cvars)
Happens to me too. You're welcome.