Title says it all.
Lemme 'splain ... In Mercenaries, players will be able to save their items to the server after "registering", aka picking a 4-digit "PIN" number so that their items can be saved in a global array. When they join the server later, they'll need to provide their PIN so that they can get their stuff back.
However, I'd like to make things more convenient for players by making it so that their PIN is stored in their ini and automatically inputted (via an Enter script) when they join the game. How can I do this? I heard ZH does this with achievements or something.
And no, cheating (via players peeking at and editing their ini's) will not be possible. All of the player's weapons and items get stored on the server. The only thing that will be stored in their ini is their ID number.
So yeah, can anyone halp?
How do I save a number to a player's .ini?
How do I save a number to a player's .ini?
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)

Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)

-
- Forum Regular
- Posts: 262
- Joined: Wed Jun 06, 2012 2:15 am
RE: How do I save a number to a player's .ini?
This may not be possible, since you can't manipulate strings in any way dynamically, unfortunately. In Zandronum, however, you could probably use Ijon's stralloc() lib to build a string containing the PIN, then use ConsoleCommand() with archivecvar to store it.
ZH probably just uses archivecvar with a specific boolean to tell whether the achievement has been completed or not.
The only way you could get around this is to have a really hackish method of storing each pin digit as a separate cvar, using archivecvar to store each one depending on the digit. Here is a simple (pseudo code) example:
Repeat for each digit in the pin. Then, when loading:
Yeah, extremely hacky and messy but it's the only way I can think of for dynamic number loading.
ZH probably just uses archivecvar with a specific boolean to tell whether the achievement has been completed or not.
The only way you could get around this is to have a really hackish method of storing each pin digit as a separate cvar, using archivecvar to store each one depending on the digit. Here is a simple (pseudo code) example:
Code: Select all
switch(digit1)
{
case 0:
ConsoleCommand("archivecvar pin_digit1 0");
break;
case 1:
ConsoleCommand("archivecvar pin_digit1 1");
break;
case 2:
ConsoleCommand("archivecvar pin_digit1 2");
break;
....
}
Code: Select all
switch(GetCVar("pin_digit1"))
{
case 0:
mypin[0] = 0;
break;
case 1:
mypin[0] = 1;
break;
....
-
- Frequent Poster Miles card holder
- Posts: 901
- Joined: Mon Jun 04, 2012 5:07 am
RE: How do I save a number to a player's .ini?
well if we have access to strparam:
also, if you can use stralloc, you necessarily have access to strparam - stralloc uses strparam extensively to rebuild strings
Code: Select all
int conPIN = 2600;
int conStr = StrParam(s:"set derp_pin", d:conPIN, s:" ", d:GetActorProperty(0, APROP_Health)) );
ConsoleCommand(conStr);
Last edited by Ijon Tichy on Wed Jul 18, 2012 3:48 am, edited 1 time in total.
-
- Zandrone
- Posts: 1244
- Joined: Thu Jun 28, 2012 9:07 pm
- Location: Rwanda
RE: How do I save a number to a player's .ini?
You can also use the 98d way of storing a CVar currently, though its huge compared to Zandronum's StrParam, so if you want it I can provide it.
RE: How do I save a number to a player's .ini?
I need it, dude.