How do you save variables?

Discuss all aspects related to modding Zandronum here.
Post Reply
Catastrophe
Retired Staff / Community Team Member
Posts: 2566
Joined: Sat Jun 02, 2012 2:44 am

How do you save variables?

#1

Post by Catastrophe » Sat Jun 23, 2012 9:32 am

.
Last edited by Catastrophe on Fri May 11, 2018 7:32 pm, edited 1 time in total.

Ijon Tichy
Frequent Poster Miles card holder
Posts: 901
Joined: Mon Jun 04, 2012 5:07 am

RE: How do you save variables?

#2

Post by Ijon Tichy » Sat Jun 23, 2012 9:57 am

Well, these days you have access to StrParam, so something like this would work

Code: Select all

function void saveCVar(int cvar, int val)
{
    int query = StrParam(s:"set ", s:cvar, s:" ", d:val);
    int query2 = StrParam(s:"archivecvar ", s:cvar);
    ConsoleCommand(query);
    ConsoleCommand(query2);
}
Note that this is EXTREMELY easy to screw with, so don't use it if you can avoid it.
Last edited by Ijon Tichy on Sat Jun 23, 2012 10:03 am, edited 1 time in total.

Catastrophe
Retired Staff / Community Team Member
Posts: 2566
Joined: Sat Jun 02, 2012 2:44 am

RE: How do you save variables?

#3

Post by Catastrophe » Sat Jun 23, 2012 10:28 am

.
Last edited by Catastrophe on Fri May 11, 2018 7:32 pm, edited 1 time in total.

Ijon Tichy
Frequent Poster Miles card holder
Posts: 901
Joined: Mon Jun 04, 2012 5:07 am

RE: How do you save variables?

#4

Post by Ijon Tichy » Sat Jun 23, 2012 10:43 am

If we're using it on the client side to save user variables:
> ACS script does saveCVar("herp_derp", 42)
> user promptly puts in "herp_derp 9239"
> later ACS script does GetCVar("herp_derp")

Yeah.

Catastrophe
Retired Staff / Community Team Member
Posts: 2566
Joined: Sat Jun 02, 2012 2:44 am

.

#5

Post by Catastrophe » Sat Jun 23, 2012 10:54 am

.
Last edited by Catastrophe on Fri May 11, 2018 7:32 pm, edited 1 time in total.

User avatar
Ivan
Addicted to Zandronum
Posts: 2228
Joined: Mon Jun 04, 2012 5:38 pm
Location: Omnipresent

RE: How do you save variables?

#6

Post by Ivan » Sat Jun 23, 2012 11:05 am

The best method of doing it is the way the ranker works in Jumpmaze if it's essential to your game. Or else, the way ZH did their achievements could be a nice way for you.

Is it for hats/pets ? :P
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===

Catastrophe
Retired Staff / Community Team Member
Posts: 2566
Joined: Sat Jun 02, 2012 2:44 am

RE: How do you save variables?

#7

Post by Catastrophe » Sat Jun 23, 2012 11:08 am

.
Last edited by Catastrophe on Fri May 11, 2018 7:33 pm, edited 1 time in total.

User avatar
Ivan
Addicted to Zandronum
Posts: 2228
Joined: Mon Jun 04, 2012 5:38 pm
Location: Omnipresent

RE: How do you save variables?

#8

Post by Ivan » Sat Jun 23, 2012 11:34 am

Catastrophe wrote: Yep, I want to make it unlockable. How did ZH do it?
I wish I knew, I could use it or learn from it. :P
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===

Catastrophe
Retired Staff / Community Team Member
Posts: 2566
Joined: Sat Jun 02, 2012 2:44 am

RE: How do you save variables?

#9

Post by Catastrophe » Sat Jun 23, 2012 11:36 am

.
Last edited by Catastrophe on Fri May 11, 2018 7:33 pm, edited 1 time in total.

ZzZombo
Forum Regular
Posts: 323
Joined: Mon Jun 11, 2012 12:11 pm
Location: Ravenholm

RE: How do you save variables?

#10

Post by ZzZombo » Tue Jun 26, 2012 11:53 am

As I remember, ZH just encrypts their CVARs by some algorithm which was hacked later :(
Last edited by ZzZombo on Tue Jun 26, 2012 11:54 am, edited 1 time in total.
QZRcon - Qt-based tool for Zandronum/Skulltag servers!
#grandvoid funny stats

Ijon Tichy
Frequent Poster Miles card holder
Posts: 901
Joined: Mon Jun 04, 2012 5:07 am

RE: How do you save variables?

#11

Post by Ijon Tichy » Thu Jun 28, 2012 8:12 am

okay i'm back
Catastrophe wrote: Anyway to hide scripts? At least from an idiot that just lazily opened up slade?
you do realise it's a trivial matter to just do a diff on your config file and see which variables were added/removed/changed, right?

also, listacs
Catastrophe wrote: Yep, I want to make it unlockable. How did ZH do it?
if I had to guess, it used a multitude of obscurely named variables with some simple scrambling scheme, given how much of a pain in the ass it would be (and how completely useless it would be in this case) to add something like twofish encryption, considering we get all of four bytes to easily work with
I have no idea, considering I haven't so much as looked at ZH for months

proper encryption in ACS is likely to remain a hard problem for a long time, by the way - although if I'm wrong and there's already been a cipher function made for ACS, I'm all ears
dear god does it sound painful to port, though

XutaWoo
Forum Regular
Posts: 113
Joined: Mon Jun 04, 2012 7:04 am

RE: How do you save variables?

#12

Post by XutaWoo » Thu Jun 28, 2012 8:41 am

Keep in mind, most people have no obligation to play your mod. They just have to download it, and if they don't want it any more they can delete it and actually gain stuff. Granted, it's stuff they already had, but they're not wasting money or anything to gain it back.

Let people cheat if they want. If letting people have the unlockables would cause problems, the people who would unlock 'em would cause problems as well. Sure, people may be miffed when they spent however much time it takes to unlock the stuff and then a way to instantly unlock everything came out, but c'est la vie.
[spoiler]Image[/spoiler]
Image

Watermelon
Zandrone
Posts: 1244
Joined: Thu Jun 28, 2012 9:07 pm
Location: Rwanda

RE: How do you save variables?

#13

Post by Watermelon » Fri Jun 29, 2012 5:11 pm

Blue msg me on TS (when you get back), I got a safe way to use StrParam cvar saving safely
Last edited by Watermelon on Fri Jun 29, 2012 5:12 pm, edited 1 time in total.

Zupoman
Forum Regular
Posts: 110
Joined: Tue Jun 26, 2012 6:30 pm

RE: How do you save variables?

#14

Post by Zupoman » Sun Jul 01, 2012 8:04 pm

Oh, I know how zh saves achievements. I know it because I was trying to find my .ini file, and looked at it "accidentally". Actually, it encodes it some way.

Code: Select all

x_zh_pro6=4632
x_zh_pro5=1728
x_zh_pro4=3438
x_zh_pro3=8740
x_zh_pro2=15687
x_zh_pro1=105468
x_zh_pro0=188
x_zh_global3=135280
x_zh_global2=119497
x_zh_global1=102768
x_zh_global0=130
Copy it into your ini file into correct place and you will have my achievements.

Tho, I think that this can be improved that just copying it to your .ini file won't give you all things.

I've never messed up with those CVAR things, so I may say something stupid, but:

You can try dividing/multipling those variables with things from playerinfo CCMD, causing some magic effects, and then encoding it by multipling/dividing them again, but oppositely. This can give you big advantage over those biatches that want everything free for them.

Post Reply