Jump to content
Sign in to follow this  
rwake345

Saving Variables

Recommended Posts

Hey everyone,

I am making a mission and am trying to add a money system.

At this moment we have stuff working, but we do not know how to save the amount of money, at this moment you just get $100 on login.

Would you save it to a MySQL database? If so how do you do that?

I am unsure of what to save the amount of money to, so if anyone could help that would be great.

Share this post


Link to post
Share on other sites

You could store the stuff into an array for example http://community.bistudio.com/wiki/Array

But it will be gone when the mission/server restarts.

To have it persistent, is quite complicated. Only clues I can give... in ArmA2 there was a command to write values to the clipboard.

You would then need to code an small app, that monitors the clipboard and writes the values to the database. This should also work the other way around.

But it's not very simple ^^

Edited by dga

Share this post


Link to post
Share on other sites

I have never used these commands, but profileNamespace and saveprofileNamespace might be able to accomplish what you are looking for. These were initially implemented in TOH, then later in A2OA, and should also be in A3. What they do is save a variable to your profile that would persist after you log off and then reload when you log back on. This thread can give you an idea of how it works (it is from TOH but should still be applicable): http://forums.bistudio.com/showthread.php?122995-profileNamespace-how-to-use

Here is an example of how it might work:

// Give the player $100 and save that amount in a variable called "money" in the player's profile name space.
profileNamespace setVariable ["money", 100];

// Save all the variables in the player's profile to a file in case the player disconnects.logs off.
saveprofileNamespace;

//Find out how much money the player has.
_currentMoney = profileNamespace getVariable "money"; // Should return 100.

//Give the player $10 more dollars.
_currentMoney = _currentMoney + 10;
profileNamespace setVariable ["money", _currentMoney];

// Save all the variables in the player's profile (again) to a file in case the player disconnects.
saveprofileNamespace;

Make sure you see the warnings about usting saveprofileNamespace too often as it uses a lot of resources.

Edited by Loyalguard
Expanded example

Share this post


Link to post
Share on other sites

Would this work in ArmA 3? Cause this is a take on helicopters command is it now also an arma 3 command?

Share this post


Link to post
Share on other sites

wait for java if you want to save data across server restarts.. writing binary files is easssssssssyyyyyyyy

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×