Origins Housing Script

Assomnia

New Member
Hey everyone,

I'm working on a OverPochIns server with a lot of script and stuff. I took a few script from here and there and today I have to write on the forum because I'm really stuck on something.
I upload the script it self may be easier for u guys.

As you can see there is password in place for the stronghold where the houses, garage and pyramid don't.
I would like to put password on every each buildings and this is where I'm stuck, how should I manage that ?
Can somebody help with this ?


The original files are the one with the _save on it. The other one are the one I try things on.

https://mega.nz/#!wAISGJRB!PpKWcktC6oya0ZLBlR5nvEdjrnAEtGJy9MtDNy7lga8
 
this is what I THINK is happening here (I dont know shit about Origins as its an abomination).

Player builds something and "locks" it. The lock code is saved in the database, see the code in the screenshot is publishing the combination to the database.
2016-01-12_14-25-42.png

At some point, when the server starts, these player built buildings are loaded and the "combination" is retrieved from the database and set as a variable attached to the building.

Then you come along and unlock it. The server retrieves the lock code into _combination variable then compares what you enter in the dialog to that .. if it matches, its unlocked
Code:
if(_typeOfCursorTarget == "krepost") then {
    private["_combination","_ok"];
    _combination = _cursorTarget getVariable ["CharacterID","0"];  
    dayz_combination = "";
    _ok = createdialog "SafeKeyPad";
    waitUntil{!dialog};
    if(_combination == dayz_combination) then {
        _strongholdCode = true;
        OriginsLockUnlock = [_cursorTarget,_typeOfCursorTarget,_action,dayz_playerUID,dayz_combination];
    };
} else {
    OriginsLockUnlock = [_cursorTarget,_typeOfCursorTarget,_action,dayz_playerUID,"0"];
};
publicVariableServer "OriginsLockUnlock";

Now you want to do this with EVERY building on the map? You need to put each building into a database table with a characterID set with the combination. You need to retrieve that combination from the database so you can compare it to what is entered via dialog. That code I posted a screenshot of the building being published to the database. You need to do something like that for every building someone wants to lock.

Can this be done? I am sure it can.
Can you do it yourself? Absolutely!
I dont think this would be as difficult as it might sound, post info about your database schema in the objects table. I have some other projects I am working on right now for other peoples, so give it a try and I can answer some questions as you get stuck. I think this is a good idea .. maybe, what is to stop people from locking EVERY building?



If I misunderstood what you wanted, sorry, reply with more detailed information.
 
Last edited:
You helped me already here because I absolutely didn't catch this DB part. (Very bad in coding here)

Not for every building, well just for the Origins building. Like the 6 houses (bandit + hero) and the small and big garage. And the pyramid.

In the player_build.sqf there is a question of random 6 digits code. This code which is created is going with the building in the DB then ?

How is it possible to get this back once I want to unlock ? I add a part of code isn't that good ?

EDIT : In the config file there is a "Name Lookup" where the buildings are grouped. Like DZE_Origins_Houses. Can I take this or should I use DZE_Origins_House1, DZE_Origins_House2, DZE_Origins_House3 , DZE_Origins_SG or the name of the building it self ? Like : Uroven1VelkaBudka ?
 
Last edited:
I dont think this would be as difficult as it might sound, post info about your database schema in the objects table. I have some other projects I am working on right now for other peoples, so give it a try and I can answer some questions as you get stuck. I think this is a good idea .. maybe, what is to stop people from locking EVERY building?



If I misunderstood what you wanted, sorry, reply with more detailed information.

Sure why not.

My database is like a vanilla epoch server. The buildings are stowed in the object_data with a CharacterID
 
it's important to note that Strongholds store a generated key in the characterID field and the origin houses store the players UID in the hitpoints. House code calls the hitpoints and stronghold code calls the CharacterID. You will need to make a lot of changes to the custom player_build.sqf and also edit the fnc_selfactions file. There's also some stuff you need to edit in the server monitor sqf. It could get pretty messy unless you really know what you're doing. I'd suggest putting this as a request on here . Maybe someone can do it for you? Good luck though.
 
it's important to note that Strongholds store a generated key in the characterID field and the origin houses store the players UID in the hitpoints. House code calls the hitpoints and stronghold code calls the CharacterID. You will need to make a lot of changes to the custom player_build.sqf and also edit the fnc_selfactions file. There's also some stuff you need to edit in the server monitor sqf. It could get pretty messy unless you really know what you're doing. I'd suggest putting this as a request on here . Maybe someone can do it for you? Good luck though.

Aha I see... Well unfortunatly no, I don't really no what I'm doing... As I said a bit earlier in the post I do patchwork not real code here...
We can't just do like the Stronghold ? Generating a code for the house once it's build, and store it into the characterID field. Just simply like the Stronghold. Looks so easy to just copy the same method. Because for the house once build, what is stored into the characterID ? Nothing I assume
 
Aha I see... Well unfortunatly no, I don't really no what I'm doing... As I said a bit earlier in the post I do patchwork not real code here...
We can't just do like the Stronghold ? Generating a code for the house once it's build, and store it into the characterID field. Just simply like the Stronghold. Looks so easy to just copy the same method. Because for the house once build, what is stored into the characterID ? Nothing I assume

Yes it can be done, but like I said. It's not going to be easy. You need to change a lot of code, in different files, not just your self actions file. So maybe post it as a request, ask someone with better programming skills (than you or myself) to provide the script changes? :)
 
I had a thought that this might be easier than thought, although I could be completely wrong here. Again, I knows nothing about Origins or what these buildings are so you have to check if any of my ideas sounds incorrect

Here is my scenario:
When you are looking at a building that you want to lock, check if its in the database as a lockable building (it will have the combination variable set). If not, then create selfaction code to allow player lock the building.
The files you posted include the player_build.sqf which saves the player built object into the database after creating a combination. So if we cannibalize that file and extract the parts that create a combination and then publish the 'player building' to the database, our new building will be added to the database with the combination. Visualize a player building a normal lockable building, but its placed in the same location as a default Origins building. The arrays of DZE_Origins_Stronghold and/or DZE_Origins_Houses need to include the buildings you want to lock.

So when the server starts its going to load all the buildings from the objects table along with the combinations, which is what we want. But if that building already exists at that location we have to delete the original building first which is easily done with code similiar to this http://opendayz.net/threads/release-replace-all-churches-with-enterble-models.13489/
What will remain is a building with a combination in the position where the default unlockable building was.

So, does this make sense?
  1. Server starts and loads all the player objects.
  2. Check if an identical classname object is near that location and do one of these options:
    1. Delete original object using code similiar to this
    2. Do not spawn new object, instead assign the database variables to original object.
  3. Player wanders to lockable building and there is a check performed whether the building already has a 'combination' variable set.
    1. Yes: Then do nothing, allow code to proceed as normal.
    2. No: execute selfaction that runs custom player_build.sqf code to create combination and save building and info in the database.
 
Last edited:
I had a thought that this might be easier than thought, although I could be completely wrong here. Again, I knows nothing about Origins or what these buildings are so you have to check if any of my ideas sounds incorrect

Here is my scenario:
When you are looking at a building that you want to lock, check if its in the database as a lockable building (it will have the combination variable set). If not, then create selfaction code to allow player lock the building.
The files you posted include the player_build.sqf which saves the player built object into the database after creating a combination. So if we cannibalize that file and extract the parts that create a combination and then publish the 'player building' to the database, our new building will be added to the database with the combination. Visualize a player building a normal lockable building, but its placed in the same location as a default Origins building. The arrays of DZE_Origins_Stronghold and/or DZE_Origins_Houses need to include the buildings you want to lock.

So when the server starts its going to load all the buildings from the objects table along with the combinations, which is what we want. But if that building already exists at that location we have to delete the original building first which is easily done with code similiar to this http://opendayz.net/threads/release-replace-all-churches-with-enterble-models.13489/
What will remain is a building with a combination in the position where the default unlockable building was.

So, does this make sense?
  1. Server starts and loads all the player objects.
  2. Check if an identical classname object is near that location and do one of these options:
    1. Delete original object using code similiar to this
    2. Do not spawn new object, instead assign the database variables to original object.
  3. Player wanders to lockable building and there is a check performed whether the building already has a 'combination' variable set.
    1. Yes: Then do nothing, allow code to proceed as normal.
    2. No: execute selfaction that runs custom player_build.sqf code to create combination and save building and info in the database.

Wow mate !
I followed exactly what you said here and I'm agree on all your points. But the problem is that I have no idea on how I should proceed... As I said I'm very bad in coding I'm just doing patchwork, try this and this but I can't do something from 0...
You would like to help me a bit more about that ? Or you are to busy ?

Thanks for the ideas
 
Here is my scenario:
When you are looking at a building that you want to lock, check if its in the database as a lockable building (it will have the combination variable set). If not, then create selfaction code to allow player lock the building.

But wait, there is no need to do that, because the guys need some materials to build the house in Origins. Once they have the requirements then they build the house, once the house is build a random key appear (like epoch when you have a safe).

But I'd like this code to go into the DB and then that the players can use it to open if they are aiming towards it
 
on way to work, still a bit cloudy on the exact situation here. But Friday is my coding day so something this quick I could knock out, if it is in fact this simple. One thing to clarify these buildings that you want to lock, I am assuming that they are already existing in the map placed there by origins correct?
Or are they buildings that players build but are just not lockable by default?
I will be home in a few hours and can work on something to get you started
 
No this are buildings the player can place whereever they want by the time they have the correct materials.
And on the real Origin map, the player can enter the code he wants and use it to open the house after. As it is a OverPochIns server I had to trick the stuff a bit. So the player get a random code like epoch and a safe for example. And after he use this code to enter the house.
Thanks a lot !
 
There you have a link where you can see how its build, I mean, the idea. Except that no code appear here, this is what I'd like to add ;)

 
Origins has its own lock unlock code. Houses use the players UID and the stronghold uses the code pad. One stores the code in the database CharacterID field and the other in the hitpoints field. You will need to rewrite the origins code in the servers system monitor sqf, the origins files in the origins folder on in the server pbo and the mission pbo, and not forgetting the changes need for the fnc self actions file.

The best I could do on my server was combine the plot pole management script with origin buildings, so that anyone added to your plot pole can also open and close your origin buildings (so long as they're within the radius of course. I had to do a lot of glitch checking though lol) ...

Good luck getting all the buildings to work with the keypad. If you succeed I'll give you my beans :p
 
Back
Top