Question about a new variable I made.

IIIXJokerXIII

New Member
I made a script that saves a variable I called "player_DeathTimeTick = 0" and I need this amount to be saved on server restart or player logoff. Does anyone know how to save a variable I crated to the dayz player database? I've search but I've not found anything that has worded for me yet.

Basically this is what I want
1. Script runs and sets player variable to something like player_DeathTimeTick = 15
2. player logs off or server resets player_DeathTimeTick is saved for that player in database.
3. player logs back on and the player_DeathTimeTick is set to the amount it was when player logged off.
 
If you are using epoch, I believe they still have the child:999 calls so you can create a custom sql code to insert that into a custom table in your database, and then on player login have similiar sql code to load the table data into your player variable.
Not terribly difficult, but certainly not as easy as the alternative solution. This post deals with the child:999 calls http://opendayz.net/threads/pulling-data-from-sql-table-in-script.10052/#post-42041
FYI: I had created one once (only about 15 lines of code total) where my players would choose their own private skin from my website and that choice would be saved in the database. When they logged into the game, the code would retrieve their chosen skin and apply it. So there are lots of cool customizations you can do with a child:999 but its not very secure ... back up your database daily! An alternative DB scheme, if you are running on a VPS or Dedicated server is to use iniDB which also works very well. (I realize its in the Arma3 code sections, but it works on Arma2)

The Alternative solution to messy, unpleasant custom SQL code
profilenamespace Reference page https://community.bistudio.com/wiki/profileNamespace
Here is Killzone Kids page about variables that has a little more info on using the namespaces
http://killzonekid.com/arma-scripting-tutorials-variables-part-2/

When player logs off exec this code
Code:
profilenamespace setvariable["player_DeathTimeTick,15];
saveprofilenamespace;

When player logs in, exec this code
Code:
player_DeathTimeTick = profilenamespace getvariable["player_DeathTimeTick,15];
 
Last edited:
Thanks for the reply...That's some good info and I will see what works best for me and post it here later. But I may try something with that iniDB that looks like it could be real useful. My script is basically a death choice. When a player dies each player_DeathTimeTick = 1 minute that the player is unconscious. The amount of the Tick is based on how the player dies and how many AI's are near the player when he is killed. The player can chose to start over deleting his body and gear immediately or wait until his deathTimeTick = 0 and the player will recover with all of his stuff. Also near by players can recover the player faster with items in game. I have it now so that if a player logs out with a + DeathTimeTick it kills the player and delete their stuff. I want it to be something they can log in and out with and wait on the time or other players to save them :) This is the last minute of a recovering player that has the choice to start over.

 
that was something like arma3 wasteland i think. you get killed but have a minute for a player to revive you or you can choose to die immediately ..... i think
 
this would be interesting for a human punishment.
Say a player commits a murder. it adds a '1' to the ticktimer. but instead of having the tick timer at the time of death, it happens at login. so the more you murder, the longer timer you have before you can log into the server, adding a sense of "should i kill this guy or not?" does that all make since? more of a tweek of your idea.
 
Code:
profilenamespace setvariable["player_DeathTimeTick",15]; //don't forget the closing " 
saveprofilenamespace;


To retrieve that variable just use this: (ShootingBlanks, you missed a closing quote on both examples)

Code:
player_DeathTimeTick = profilenamespace getvariable "player_DeathTimeTick";

If you want your variable to be available globally (you could do a lot with your script server side) , then use this:

Code:
_variableTick = profilenamespace getvariable "player_DeathTimeTick";
player setVariable ["player_DeathTimeTickGlobal", _variableTick, true]; //True = Global

I use something similar to set a factions variable on players that can be read by the server for humanity rewards based on faction! :)
 
Last edited:
Code:
profilenamespace setvariable["player_DeathTimeTick",15]; //don't forget the closing "
saveprofilenamespace;
To retrieve that variable just use this: (ShootingBlanks, you missed a closing quote on both examples)
That was a test to see if anyone was actually paying attention :rolleyes:
 
Amen to that ..
i usually write in big letters that anything i post needs to be checked .. double checked and virus scanned
 
Back
Top