[Project] Basebuilding 1.2 change Code

havent tested charges yet as the as50 is more common on my server,but i deff will,also its only the door pieces,very strange

Maybe something seperate with the concrete doors then, I didn't specifically test those as they aren't used much on my server. The code on github definitely fixed all the other items being destroyable for me though.

Also the sql statement to update all your buildables dead owners is

Code:
UPDATE instance_deployable d LEFT JOIN (
SELECT DISTINCT d.owner_id, s.unique_id
FROM instance_deployable d
LEFT JOIN survivor s ON s.id = d.owner_id
WHERE s.is_dead =1
) AS dead ON dead.owner_id = d.owner_id
LEFT JOIN survivor live ON live.unique_id = dead.unique_id
SET d.owner_id = live.id WHERE live.is_dead =0
 
Maybe something seperate with the concrete doors then, I didn't specifically test those as they aren't used much on my server. The code on github definitely fixed all the other items being destroyable for me though.

Also the sql statement to update all your buildables dead owners is

Code:
UPDATE instance_deployable d LEFT JOIN (
SELECT DISTINCT d.owner_id, s.unique_id
FROM instance_deployable d
LEFT JOIN survivor s ON s.id = d.owner_id
WHERE s.is_dead =1
) AS dead ON dead.owner_id = d.owner_id
LEFT JOIN survivor live ON live.unique_id = dead.unique_id
SET d.owner_id = live.id WHERE live.is_dead =0
ah nice, thats even less hassle, lol,took me forever to even figure that out,new to this whole thing but trying and this will do them all at once as opposed to my manual method?
 
ah nice, thats even less hassle, lol,took me forever to even figure that out,new to this whole thing but trying and this will do them all at once as opposed to my manual method?

yeah run it before your server restarts and all dead survivors who now have a new character will be updated
 
If you want that they stay as owners of their buildables you can also change the following:

player_remove.sqf

change
Code:
if ( _ownerID == dayz_characterID ) then {
call _func_ownerRemove;
};
to
Code:
if ( _ownerID == dayz_playerUID) then {
call _func_ownerRemove;
};

--------------------------

player_build.sqf

change
Code:
_object setVariable ["CharacterID",dayz_characterID,true];
dayzPublishObj = [dayz_characterID,_object,[_dir,_location],_classname];

to
Code:
_object setVariable ["CharacterID",dayz_playerUID,true];
dayzPublishObj = [dayz_playerUID,_object,[_dir,_location],_classname,_playeruid];


It will change it so the BaseBuilding Script will use the PlayerUID instead of the CharacterID which doesn't change if you die. The only issue could be with ArmaX Users who have letters in their PlayerUID.

You can use gnifs fix to change the CharacterIDs to PlayerUIDs in the table

https://github.com/vbawol/DayZhiveEpoch/pull/1#issuecomment-17979943

For the destructable issues may try this fix

http://opendayz.net/threads/base-building-dayz-1-2-released.8579/page-9#post-28813
 
I'm currently trying to implement a random Code which is saved into the fuel field.

_fuel= _code / 100000
_code= _fuel * 100000

I also tried to write a function that gives you the ability to edit the code manually if you're the owner of the object. If it works you'll have as owner always a scroll down menu "Edit Code" and can set the code to any 5 digits long number ;)

As soon as it (and if it) works I will release it here.
 
Okay atm the Build Recipe Menu isn't showing anymore. I will post it nevertheless maybe someone see the mistake earlier than me ;)

This isn't working at the moment, its only a capture where I'm stuck at the moment, don't put this onto your server if you don't know what you're doing!

Added to defines.hpp (at the end)
Code:
class KeypadGateNew {
idd = -1;
movingEnable = false;
controlsBackground[] = {};
controls[] = {
"B1",
"B2",
"B3",
"B4",
"B5",
"B6",
"B7",
"B8",
"B9",
"B0",
"BEnter",
"BAbort",
"KeypadImage",
"NumberDisplay"
};
objects[] = {};
class B1 {
idc = -1;
type = 1;
style = 2;
moving = false;
x = 0.39;
y = 0.39;
h = 0.08;
w = 0.06;
font = "Zeppelin32";
sizeEx = 0.05;
// action uses script commands to close dialog and display a hint
action = "CODEINPUT set [count CODEINPUT, 1]; ctrlSetText [1099, str CODEINPUT];";
text = "";
default = false;
colorText[] = {0,0,0,1}; // white
colorFocused[] = {0.1,0.1,0.1,0.1}; // green
colorShadow[] = {0,0,0,0}; // darkgrey
colorBorder[] = {0.5,0.5,0.5,0}; // grey
colorBackground[] = {0.7,0.7,0.7,1};
colorBackgroundActive[] = {0.1,0.1,0.1,0.3}; // green
colorDisabled[] = {1,0,0,1}; // red
colorBackgroundDisabled[] = {0.5,0.5,0.5,0}; // grey
borderSize = 0.015;
offsetX = 0.005;
offsetY = 0.005;
offsetPressedX = 0.002;
offsetPressedY = 0.002;
soundEnter[] = {"",0,1}; // NoSound
soundPush[] = {"",0,1}; // NoSound
soundClick[] = {"\dayz_sfx\action\cell\dtmf_1.ogg",0.5,1}; // NoSound
soundEscape[] = {"",0,1}; // NoSound
};
 
class B2 : B1 {
x = 0.47;
text = "";
soundClick[] = {"\dayz_sfx\action\cell\dtmf_2.ogg",0.5,1};
action = "INPUT set [count INPUT, 2]; ctrlSetText [1099, str INPUT];";
};
class B3 : B1 {
x = 0.55;
text = "";
soundClick[] = {"\dayz_sfx\action\cell\dtmf_3.ogg",0.5,1};
action = "INPUT set [count INPUT, 3]; ctrlSetText [1099, str INPUT];";
};
class B4 : B1 {
y = 0.50;
text = "";
soundClick[] = {"\dayz_sfx\action\cell\dtmf_4.ogg",0.5,1};
action = "INPUT set [count INPUT, 4]; ctrlSetText [1099, str INPUT];";
};
class B5 : B4 {
x = 0.47;
text = "";
soundClick[] = {"\dayz_sfx\action\cell\dtmf_5.ogg",0.5,1};
action = "INPUT set [count INPUT, 5]; ctrlSetText [1099, str INPUT];";
};
class B6 : B4 {
x = 0.55;
text = "";
soundClick[] = {"\dayz_sfx\action\cell\dtmf_6.ogg",0.5,1};
action = "INPUT set [count INPUT, 6]; ctrlSetText [1099, str INPUT];";
};
class B7 : B1 {
y = 0.61;
text = "";
soundClick[] = {"\dayz_sfx\action\cell\dtmf_7.ogg",0.5,1};
action = "CODEINPUT set [count CODEINPUT, 7]; ctrlSetText [1099, str CODEINPUT];";
};
class B8 : B7 {
x = 0.47;
text = "";
soundClick[] = {"\dayz_sfx\action\cell\dtmf_8.ogg",0.5,1};
action = "INPUT set [count INPUT, 8]; ctrlSetText [1099, str INPUT];";
};
class B9 : B7 {
x = 0.55;
text = "";
soundClick[] = {"\dayz_sfx\action\cell\dtmf_9.ogg",0.5,1};
action = "INPUT set [count INPUT, 9]; ctrlSetText [1099, str INPUT];";
};
 
class B0 : B8 {
y = 0.72;
text = "";
soundClick[] = {"\dayz_sfx\action\cell\dtmf_0.ogg",0.5,1};
action = "INPUT set [count INPUT, 0]; ctrlSetText [1099, str INPUT];";
};
class BEnter : B9 {
y = 0.72;
text = "";
soundClick[] = {"\dayz_sfx\action\cell\dtmf_hash.ogg",0.6,1};
action = "closeDialog 0; nul = [INPUT] execVM 'dayz_code\external\keypad\fnc_keyPad\codeCheck.sqf';";
};
class BAbort : B7 {
y = 0.72;
text = "";
soundClick[] = {"\dayz_sfx\action\cell\dtmf_star.ogg",0.6,1};
action = "closeDialog 0; INPUT = [];";
};
class KeypadImage {
idc = -1;
type = CT_STATIC;
style = ST_PICTURE;
colorText[] = { };
colorBackground[] = { };
font = "Zeppelin32";
sizeEx = 0.023;
x = 0.35; y = 0.2;
w = 0.3; h = 0.8;
text = "dayz_code\external\keypad\pics\keypad.paa";
};
class NumberDisplay {
idc = 1099;
type = CT_STATIC ; // defined constant
style = ST_LEFT; // defined constant
colorText[] = { 1, 0, 0, 1 };
colorBackground[] = { 1, 1, 1, 0 };
font = Zeppelin32; // defined constant
sizeEx = 0.028;
x = 0.38; y = 0.24;
w = 0.23; h = 0.1;
text = "";
};
};

----------------------------------------

Added to variables.sqf under //Arrays
Code:
INPUT= [];

----------------------------------------

player_build.sqf
directly above
Code:
//--------------------------------
 
switch (_classname) do

I added
Code:
_code = random(99999);

Database part at the end is changed to the following
Code:
// Send to database
_fuel = _code / 100000;
_object setVariable ["characterID",dayz_playerUID,true];
_object setVariable ["Classname",_classname,true];
dayzPublishObj = [dayz_playerUID,_object,[_dir,_location],_classname, _fuel];
publicVariableServer "dayzPublishObj";
if (isServer) then {
dayzPublishObj call server_publishObj;
};

----------------------------------------

fn_selfActions.sqf
between part // Remove Object from code
and // Disarm Booby Trap Action
added
Code:
if (_ownerid == dayz_getplayerUID) {
_isowner = true;
};
 
// Edit Code from Object
if((typeOf(cursortarget) in allbuildables_class) && _isowner && _canDo && !procBuild && !remProc) then {
if (s_player_codeEdit < 0) then {
s_player_codeEdit = player addaction [("<t color=""#11F2F6"">" + ("Edit Code") +"</t>"),"dayz_code\external\keypad\fnc_keyPad\codeEdit.sqf","",5,false,true,"",""];
};
/*else {
player removeAction s_player_codeEdit;
s_player_codeEdit = -1;*/
 
} else {
player removeAction s_player_codeEdit;
s_player_codeEdit = -1;
};

and at the end added
Code:
player removeAction s_player_codeEdit;
s_player_codeEdit = -1;

----------------------------------------

server_publishObject.sqf
added
Code:
_fuel = _this select 4;

changed
Code:
_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _charID, _worldspace, [], [], 0,_uid];
to
Code:
_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _charID, _worldspace, [], [], _fuel,_uid];

added
Code:
_code = _fuel * 100000;
_object setVariable ["Code", _code,true];
 
_object setVariable ["Classname", _class,true];
 
_object setVariable ["ObjectUID", _uid,true]

----------------------------------------

servermonitor.sqf
added
Code:
_code = _fuel * 100000;
_object setVariable ["Code", _code, true];
_object setVariable ["Classname", _type,true];

----------------------------------------

Wrote this 2 new .sqfs and put them inside \dayz_code\external\keypad\fnc_keyPad\

editCode.sqf
Code:
//addaction sends [target, caller, ID, (arguments)]
private ["_displayok2","_lever2"];
//_id = _this select 2;
//_lever removeAction _id;
_lever2 = cursortarget;
//_dir = direction _lever;
//_pos = getPosATL _lever;
//_uid= [_dir,_pos] call dayz_objectUID2;
_displayok2 = createdialog "KeypadGateNew";

----------------------------------------

codeCheck.sqf
Code:
_panel = cursortarget;
_worldspace = getPos _panel;
_classname = getVariable "Classname";
INPUT = _this select 0;
//hint format["keycode after enter: %1", keyCode];
sleep 3;
_codeinput = INPUT;
//hint format["Keycode: %1 | CodeInput: %2", _code, _inputCode];
_convertInput =+ _codeinput;
for "_i" from 0 to (count _convertInput - 1) do {_convertInput set [_i, (_convertInput select _i) + 48]};
//hint format["Keycode: %1 | CodeInput: %2", _code, (toString _convertInput)];
 
// compare arrays to see if code matches
if ( (toString _convertInput) > 0 && (toString _convertInput) < 10000) then {
cutText [format["You have successfully changed your code to: %1",(toString _convertInput)], "PLAIN DOWN",1];
playsound "beep";
sleep 0.5;
playsound "beep";
sleep 0.5;
playsound "beep";
_fuel = (toString _convertInput) / 100000;
dayzPublishObj = [dayz_playerUID,_panel,_worldspace,_classname, _fuel];
publicVariableServer "dayzPublishObj";
if (isServer) then {
dayzPublishObj call server_publishObj;
};
} 
else { cutText ["Failed to change your code, please use exact 5 numbers!", "PLAIN DOWN"];breakOut "exit";
};
 
INPUT = [];
 
fn_selfActions.sqf
between part // Remove Object from code
and // Disarm Booby Trap Action
added
Code:
// Edit Code from Object
if((typeOf(cursortarget) in allbuildables_class) && _canDo && !procBuild && !remProc && (_ownerID == dayz_playerUID)) then {
if (true) then {
if (s_player_codeEdit < 0) then {
s_player_codeEdit = player addaction [("<t color=""#8E11F5"">" + ("Edit Code") +"</t>"),"\dayz_code\external\keypad\fnc_keyPad\editCode.sqf"];
};
} else {
player removeAction s_player_codeEdit;
s_player_codeEdit = -1;
};
} else {
player removeAction s_player_codeEdit;
s_player_codeEdit = -1;
};

and at the end added
Code:
player removeAction s_player_codeEdit;
s_player_codeEdit = -1;

Instead of above added this:

Code:
// Edit Code from Object
if((typeOf(cursortarget) in allbuildables_class) && _isowner && _canDo && !procBuild && !remProc) then {
if (s_player_codeEdit < 0) then {
s_player_codeEdit = player addaction [("<t color=""#11F2F6"">" + ("Edit Code") +"</t>"),"dayz_code\external\keypad\fnc_keyPad\codeEdit.sqf","",5,false,true,"",""];
};
/*else {
player removeAction s_player_codeEdit;
s_player_codeEdit = -1;*/
 
else {
player removeAction s_player_codeEdit;
s_player_codeEdit = -1;
};
};


and at the end added
Code:
player removeAction s_player_codeEdit;
s_player_codeEdit = -1;


Now Build Recipe reappears again. Building works. The random code has one decimal place so I need to round this. Also the edit Code Function doesn't appear think is because an if argument will see which one.

Stay tuned :)
 
Made some new improvements to fix some bugs, will post everything when it works.

I'm stuck atm with

Code:
_object setVariable ["Code",_code,true];
_keycode = _object getVariable["Code","0"];

If I try to get the value of it with

Code:
diag_log format["KIKYOU DEBUG: Value of _keycode: %1",_keycode];

It shows in the player.build.sqf only values "any" also in the checkCode.sqf and enterCode.sqf. This breaks everything cause the values can't be passed to the other functions. So the Keycode isn't recognized and won't be accepted, same for other values I need for the Edit Code function.

I have also added the setVariable codes to the server_PublishObject.sqf . There are the right values shown but no where else. Is it a issue that getVariable only works for serverside scripts? But why it had worked before at the normal Basebuilding Clientside Script?

Would be really awesome if anybody could point me into the right direction...

Thanks!
 
Made some new improvements to fix some bugs, will post everything when it works.

I'm stuck atm with

Code:
_object setVariable ["Code",_code,true];
_keycode = _object getVariable["Code","0"];

If I try to get the value of it with

Code:
diag_log format["KIKYOU DEBUG: Value of _keycode: %1",_keycode];

It shows in the player.build.sqf only values "any" also in the checkCode.sqf and enterCode.sqf. This breaks everything cause the values can't be passed to the other functions. So the Keycode isn't recognized and won't be accepted, same for other values I need for the Edit Code function.

I have also added the setVariable codes to the server_PublishObject.sqf . There are the right values shown but no where else. Is it a issue that getVariable only works for serverside scripts? But why it had worked before at the normal Basebuilding Clientside Script?

Would be really awesome if anybody could point me into the right direction...

Thanks!

Still having that issue.

_code is calculated like that

Code:
_coder = random(99999);
if (_coder < 10000) then {
_coder = _coder + 10000;
};
_code = round _coder;

Then I convert it to a value which fits for the fuel field in the database and send it to my modified server_publishObject.sqf just as normal
Code:
_fuel = _code / 100000;
dayzPublishObj = [dayz_playerUID,_object,[_dir,_location],_classname, _fuel];
publicVariableServer "dayzPublishObj";
if (isServer) then {
dayzPublishObj call server_publishObj;
};

At server_publishObject.sqf I added this line to get hands on _fuel
Code:
_fuel =_this select 4;

After passing to the db I converted the fuel value back to the code
Code:
_code = _fuel * 100000;

Then set this to the variable
Code:
_object setVariable ["Code", _code,true];

If I do now for my new script
Code:
_keycode = _object getVariable["Code","0"];
diag_log format["KIKYOU DEBUG: Value of _keycode: %1",_keycode];

It does not work cause the value of _keycode is "any".

I tried to convert _code tostring and use parseNumber but I don't think that this is what I need (didn't work though), cause the _charID or the _uid works like a charm.
The variables are also added to the private array.

Any suggestions?

Thanks!

Edit: Now I tried to pass _code directly to the server_publishObj and don't calculate it back. But same result "Access denied" :/

Edit2: I also checked datatypes with typename ... _code is SCALAR like _uid

I ran out of ideas. :/
 
Managed to find the bug which was holding me back.

Going to fix the last bug that the edit Button do not save the new Code, if this is done everything works fine.

When you build a 5 digits long code will be shown which work and is saved in fuel field of the object.
With the Edit Button you're able to enter your own code and change it to that one, if you're the owner.
You stay the owner of your buildables untill you would change your CD Key ;)

Edit: I fixed everything, give me some time to tidy up the code and add some comments. Then I will write a tutorial how I did this. This will definitely work for Epoch, I didn't test other Mods ;)
 
You also mention variables.sqf in the code that needs to be changed, this means the script is only for dedicated boxes as for hosted gameservers the variables sits tidely into the core code of dayz (dayz_code) and can not be changed.

Unless it can get variables from a different file as well, this script-addition will be loved by many.

Awesome job
 
You also mention variables.sqf in the code that needs to be changed, this means the script is only for dedicated boxes as for hosted gameservers the variables sits tidely into the core code of dayz (dayz_code) and can not be changed.

Unless it can get variables from a different file as well, this script-addition will be loved by many.

Awesome job

Why not put variables.sqf inside your mission pbo and change init.sqf accordingly

Code:
call compile preprocessFileLineNumbers "NEWLOCATION\variables.sqf";
 
Why not put variables.sqf inside your mission pbo and change init.sqf accordingly

Code:
call compile preprocessFileLineNumbers "NEWLOCATION\variables.sqf";


That would be awesome but as i not host my server myself I do not even have access to that variables.sqf that is used in the dayz_code so how do I know what is used exactly to make my server work ? P.S. I tried that but server don't even start btw
 
Everything works at the moment got to change the 5 digit code to 4 digit code length, cause the servermonitor just recieves rounded 3 digits after the comma. That would change code slightly on restart.

So now it uses 4 digits and work like a charme

The only thing is at the moment that the 1 at the keypanel for editing is a little bit crazy. Should be an issue of defines.hpp.

If this is fixed its completed and I will release everything :)
 
allright great, one question though, you mention to change the db also to the players UID instead of ID and refer to gnif's post, now i am an original donkey when it comes to making changes or write anything in a database, ive looked it his code and honestly do not know what to do with it as he mentions to totally update on the new version.

I am lost here.
 
Back
Top