Jump to content
  • 0

Safe code change script


Meowzors

Question

Was curious if there was a way to give the players a pop up box to change their safe combo.  It is really annoying trying to remember 15 safe codes and door codes in a large base.. Even more annoying for server admins being asked to change codes for players so they dont have to remember so many

Link to comment
Share on other sites

Recommended Posts

  • 0

Just call the GUI for entering a code and use it to change the code. should be simple enough and then just replace the safe when you have entered the new code

Yeah it sounds simple enough, I'm not definitely not a coder :( Not something i'd really be able to code myself, was hoping bringing the thread back might entice someone to poke at it and see if they could get it working.

Link to comment
Share on other sites

  • 0

That is a website which you are probably requiring money to have access to... I am looking for a way to make it doable in game without fee...

 

you could - simply make the tokens free? give away 100 tokens on registration or whatever. 

(the tool it's self is free, I don't attempt to draw out money for anything I do for the community)

 

you can also disable any parts you do not want users to access via the Config

 

It's a token donation system, but that doesn't mean donations have to be behind the token. Plus it draws more people to your site/forums

;)

Link to comment
Share on other sites

  • 0

k, so I have figured out how to get the pop up UI for the safe code entry to come up (in game) and get the numbers from it that are entered.  Now my problem is how do I assign the numbers to the CharID field in the database... i tried using

Code:

dayz_selectedVault setVariable[""ObjectID"",new_combination,true];
[dayz_selectedVault,(typeOf dayz_selectedVault)] spawn server_updateObject;

HOWEVER, nothing changes in the database but now I cannot access the safe until restart... Once I figure this out I will make a detailed release post.

Link to comment
Share on other sites

  • 0

Here is the codeChangeUI.hpp: http://pastebin.com/ntu2kCVD

 

Which is called from: http://pastebin.com/afUqvphu 

 

Which is called from a self_actions call in this block of self_actions...

	//Allow owner to pack vault
	if(_typeOfCursorTarget in DZE_UnLockedStorage and _ownerID != "0" and (player distance _cursorTarget < 3)) then {

		if (s_player_lockvault < 0) then {
			if(_ownerID == dayz_combination or _ownerID == dayz_playerUID) then {
				s_player_lockvault = player addAction [format[localize "STR_EPOCH_ACTIONS_LOCK",_text], "\z\addons\dayz_code\actions\vault_lock.sqf",_cursorTarget, 0, false, true, "",""];
			};
			if((getPlayerUID player in  AdminList)) then {
				_codeChange = player addAction [("<t color=""#007ab7"">" + ("Change Code...") +"</t>"), "Custom\changeCode.sqf",_cursorTarget, 0, false, true, "",""];
			};
		};

Currently, have this code only open to admins until it is working 100% then will remove the admin requirement

Link to comment
Share on other sites

  • 0

We'll looking at the code, and remember I'm on a tablet and drugged with painkillers, so double check what I'm saying, but for me it seems like your testing if the storage is locked in all 3 places, which makes no sence since you should only do it in fn_selfAction. Second is that you have no check on the length of the code, but the SQL will only hold 11 integers in characterID field. Also what's wrong with the normal UI, why not use the same variable in that UI for your script and this way save some KB in that mission file. Again I'm on a tablet so I haven't checked the original UI hpp but it would be logic in my head to use the same one, an then do the checks in your script instead of in the hpp file

And why allow code change on locked vaults in the hpp and change code script when your not allowing it in the self action

Link to comment
Share on other sites

  • 0

Couple of issues with your understanding of what is happening...

  1. I indeed do have a option created in self actions that is labeled "Change Code..." Clearly visible in my post above in the code block pulled from self_actions "_codechange=addaction blah..."
  2. once u click "change code..." it has to check if the locked vault is a safe or a lockbox, so "change code..." calls changeCode.sqf
  3. changeCode.sqf determines if it is a lockbox or safe and calls the appropriate UI which the class for which is created in codeChangeUI.hpp which is included in the description.ext so the client has access to it
  4. The length of the code entered isnt important as of yet until the script actually works and then I will put in restrictions such as length so they cant screw up their safes before releasing to my server population

My main problem for getting all of this to work lies in the code to update the item in the database to the new CharID.  I have been thinking of it a little bit and I might need to create a new safe with the same data as the old but with new charID, delete the old safe from database and then insert the new safe into the database which is leading me to think i need to call a seperate SQF when the enter button is pressed rather than just running the code needed in the action=blah;

 

EDIT: I really feel like there is a built in function in epoch that I can update the current safe in the database with but I am at a loss as to what it is

Link to comment
Share on other sites

  • 0

I have no issue understanding what your script is doing and never mind... you actually didn't read what i wrote to you, that's really clear, and taking it as an attack on you, going all defensive when it's an advise and i'm trying to help you, you might want to take it as an experience and learn some thing but again that's up to you. I'm just going to write up my own version then, as you clearly can't get advise without feeling it's an attack on you personally.

 

You might have a main problem in your script, but that's not the only problem you have in it and I tried to guide you in the right direction. Also i never said you didn't have a "Change Code..." option don't really know where you got that from?, just saying you are doing pointless checks in your scripts by checking if it is in the locked and unlocked array as checking if it's in the unlocked should be more than enough.

 

If you want to know what hive calls you can do, look up the Hive files on github, there might be a solution to your problem

Link to comment
Share on other sites

  • 0

The only check for whether or not the safe is locked in my script is the location that the self actions code is in... it is located inside the same block as pack safe(unlocked state) so the hpp file will never receive a locked safe to change codes on... I just don't understand where you are seeing that we are checking locks in 3 places is our problem understanding each other here. I wasn't really being defensive just trying to point out what seemed to me a misunderstanding of the code (it may have came off rude because I had just worked 10 hours in a miserable job... they transferred me to another location to fix their problems and these people there are driving me nuts) 

Link to comment
Share on other sites

  • 0

Thats alright, just getting a bit pissed off when I try to help and just get that kind of response

 

and sry in two places, again as i said a bit high on powerful pain killers yesterday as i had surgery

 

in the self action and the changeCode.sqf here is the example

if ((typeOf dayz_selectedVault) == "VaultStorageLocked" or (typeOf dayz_selectedVault) == "VaultStorage") then {

it's not always optimal to copy some code from the Epoch dev as it's build for a specific purpose.

like changeCode is a copy of

https://github.com/vbawol/DayZ-Epoch/blob/master/SQF/dayz_code/actions/vault_combination_1.sqf

 

But if you look closer this code will actually allow to call the keypad UI to change code on locked safes. i know you check for the safe type in fn_selfAction but why also keep that check in your change code script as we wouldn't allow it anyway.

 

I would be able if i was quick enough to place a safe of my own right next to the one i would like to change code on then unlock my own safe and then quick switch aim from my own unlock safe to the one i would actually like to change code on and the get the change code keypad on the locked safe. Yes the timing would have to be right but it's possible.

 

I will be looking in the Hive files, we might be able to find the right call we need and do a hive call directly instead of relying on the build in scripts to do it

 

change it to

if (!((typeOf dayz_selectedVault) == "VaultStorageLocked") or (typeOf dayz_selectedVault) == "VaultStorage") then {

or

if ((typeOf dayz_selectedVault) == "VaultStorage") then {

the last one would be faster and give the same result and give the result we need

Link to comment
Share on other sites

  • 0

Ah true. Didn't realize that the vaultstoragelocked was just the locked version of the safe. Maybe that is the problem with the code not changing... I'm changing the code on the unlocked safe. The unlocked safe is a active server copy of the locked safe from the database... Need to fetch the locked version and change the code on it probably for it to update in the database. Sound right?

Link to comment
Share on other sites

  • 0

https://github.com/vbawol/DayZ-Epoch/blob/master/SQF/dayz_code/compile/player_unlockVault.sqf

 

Check out line 84... when you unlock a vault it deletes the locked safe from the cache of live server and puts another version of the safe there... so we are only changing the temporary version and since the code doesnt match it will not update the original. Now looking into what happens when you lock the safe... that code will probably give us what we want to change the original

Link to comment
Share on other sites

  • 0

K, created a new sqf that is the main workhorse for this script now... What it does is copies the info from current safe, deletes safe from database, creates a new safe with previous safes info and new combo, and then inserts new safe into database. Server restart isn't for another hour or so, I uploaded the files and will test upon restart (if I don't fall asleep).  Will give results and HOPEFULLY post final files after test! :)

 

--Don't wanna post new files until I am sure they work

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...