key lock/unlock vehicle

Here is a example of my future Change Keycode for BaseBuilding Script. It does nearly the same what you have to do (change one field in the database of a particular item).

Cause there is no CHILD:999 custom Hive Request at the DayZ Epoch Hive (I'm using that), I had to find another solution.

I ended up in a good way to overcome all this problems. If everything is alright and the script can be started, I do a request to the database to delete the object. Then I rewrite everything to the database with same data only with my modified field.
I don't use deletevehicle cause this would cause that the object wouldn't be there till next restart. I set everything via setVariable and getVariable and for restarts just set them again at servermonitor. I used the fuel field cause this field isn't used for normal buildings ;)

In your case you need to change just Character_ID which is used to check if someones is the owner.

To restrict who can use this script I set that only owner can do this at buildables at the fn_selfactions.sqf

Here is my example script for MY case

Code:
private ["_object","_location","_dir","_worldspace","_objectID","_objectUID","_classname","_codeinput","_convertInput","_i","_stringInput","_numberInput","_fuel"];
_object = cursortarget;
_location = getposATL _object;
_dir = getDir _object;
_worldspace = [_dir,_location];
_objectID = _object getVariable["ObjectID","0"];
_objectUID = _object getVariable["ObjectUID","0"];
_classname = _object getVariable["Classname","0"];
_code = _object getVariable ["Code","0"];
//_objectUID = _worldspace call dayz_objectUID2;;
_codeinput = _this select 0;
sleep 3;
_convertInput =+ _codeinput;
for "_i" from 0 to (count _convertInput - 1) do {_convertInput set [_i, (_convertInput select _i) + 48]};
_numberInput = parseNumber (toString _convertInput);
 
 
if ( _numberInput > 10000 && _numberInput < 100000) then {
dayzDeleteObj = [_objectID,_objectUID];
publicVariableServer "dayzDeleteObj";
if (isServer) then {
dayzDeleteObj call server_deleteObj;
};
sleep 3;
_fuel = _numberInput / 100000;
_object setVariable ["characterID",dayz_playerUID,true];
dayzPublishObj = [dayz_playerUID,_object,[_dir,_location],_classname,_fuel,_code];
publicVariableServer "dayzPublishObj";
if (isServer) then {
dayzPublishObj call server_publishObj;
};
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";
};
else { cutText ["Failed to change your code, please use exact 5 numbers!", "PLAIN DOWN"];breakOut "exit";
_codeinput = [];
};
 
_codeinput = [];

I will later do complete tutorial for my BaseBuilding Improvement on my thread

http://opendayz.net/threads/project-basebuilding-1-2-change-code.10183/
 
Here is a example of my future Change Keycode for BaseBuilding Script. It does nearly the same what you have to do (change one field in the database of a particular item).

Cause there is no CHILD:999 custom Hive Request at the DayZ Epoch Hive (I'm using that), I had to find another solution.

I ended up in a good way to overcome all this problems. If everything is alright and the script can be started, I do a request to the database to delete the object. Then I rewrite everything to the database with same data only with my modified field.
I don't use deletevehicle cause this would cause that the object wouldn't be there till next restart. I set everything via setVariable and getVariable and for restarts just set them again at servermonitor. I used the fuel field cause this field isn't used for normal buildings ;)

In your case you need to change just Character_ID which is used to check if someones is the owner.

To restrict who can use this script I set that only owner can do this at buildables at the fn_selfactions.sqf

Here is my example script for MY case

Code:
private ["_object","_location","_dir","_worldspace","_objectID","_objectUID","_classname","_codeinput","_convertInput","_i","_stringInput","_numberInput","_fuel"];
_object = cursortarget;
_location = getposATL _object;
_dir = getDir _object;
_worldspace = [_dir,_location];
_objectID = _object getVariable["ObjectID","0"];
_objectUID = _object getVariable["ObjectUID","0"];
_classname = _object getVariable["Classname","0"];
_code = _object getVariable ["Code","0"];
//_objectUID = _worldspace call dayz_objectUID2;;
_codeinput = _this select 0;
sleep 3;
_convertInput =+ _codeinput;
for "_i" from 0 to (count _convertInput - 1) do {_convertInput set [_i, (_convertInput select _i) + 48]};
_numberInput = parseNumber (toString _convertInput);
 
 
if ( _numberInput > 10000 && _numberInput < 100000) then {
dayzDeleteObj = [_objectID,_objectUID];
publicVariableServer "dayzDeleteObj";
if (isServer) then {
dayzDeleteObj call server_deleteObj;
};
sleep 3;
_fuel = _numberInput / 100000;
_object setVariable ["characterID",dayz_playerUID,true];
dayzPublishObj = [dayz_playerUID,_object,[_dir,_location],_classname,_fuel,_code];
publicVariableServer "dayzPublishObj";
if (isServer) then {
dayzPublishObj call server_publishObj;
};
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";
};
else { cutText ["Failed to change your code, please use exact 5 numbers!", "PLAIN DOWN"];breakOut "exit";
_codeinput = [];
};
 
_codeinput = [];

I will later do complete tutorial for my BaseBuilding Improvement on my thread

http://opendayz.net/threads/project-basebuilding-1-2-change-code.10183/

This is all very awesome, but you might have accidentally put it in the wrong thread.
 
No he didn't. He was showing me what he did to get around the child:999 hive read/write. He's showing me this because i'll need to do something similar for the vehicle lock/unlock to hopefully keep vehicles locked through server restart
 
This is all very awesome, but you might have accidentally put it in the wrong thread.

If you think that you're still on the wrong way

The same method as I use to edit only one field in the database without using a custom hive request can be used to write the owner of an vehicle into the database.

Normally there is no function to do that, only a function to publish a complete new object or streaming all informations to the server. So this solution in my example is working here, too. You delete the vehicle and readd it with further informations.

This solution is the only one I can think about to use for becoming permanent owner without a custom hive request over CHILD:999 (someone else maybe have another idea)
 
It deletes them from the database but not from the game, that is the trick ;)

For real the old vehicle will stay there till server restart but will have the new variables which you define via setVariable.

After server restart the servermonitor will automatically add to the "new" vehicle the setvariable again if you define it there. So for the player there is no deleted vehicle or object for real ;)

Its just to "overwrite" the old database fields.

To delete it "local" you would've to add

deletevehicle _object;

;)
 
If you think that you're still on the wrong way

The same method as I use to edit only one field in the database without using a custom hive request can be used to write the owner of an vehicle into the database.

Normally there is no function to do that, only a function to publish a complete new object or streaming all informations to the server. So this solution in my example is working here, too. You delete the vehicle and readd it with further informations.

This solution is the only one I can think about to use for becoming permanent owner without a custom hive request over CHILD:999 (someone else maybe have another idea)

:p my bad, saw the stuff about basebuilding and i am following both threads, so i thought he might have mixed the 2 threads up... turns out it was me.
 
:p my bad, saw the stuff about basebuilding and i am following both threads, so i thought he might have mixed the 2 threads up... turns out it was me.

No problem ;)

If I have released the complete files I think it will be clearer for all to understand. Will try to comment everything that its understandable.

There are just one or two bugs left to fix, then I will release it.
 
Would appricaite it. at the moment im having issues with every sript i write. the simplier scripts that contain just a cuttext work when i call them from self actions but my more advanced scripts arnt doing anything at all let alone the desired effect. pretty sure i have a syntax error or something somewhere causing it but i don't have any errors in my rpt. Gotta work this out before i work on this vehicle lock/unlock and btw i appricaite you guys letting me work on it with help even though it'd prolly be easier for one of you with more experience to just go ahead and do it lol.
 
Would appricaite it. at the moment im having issues with every sript i write. the simplier scripts that contain just a cuttext work when i call them from self actions but my more advanced scripts arnt doing anything at all let alone the desired effect. pretty sure i have a syntax error or something somewhere causing it but i don't have any errors in my rpt. Gotta work this out before i work on this vehicle lock/unlock and btw i appricaite you guys letting me work on it with help even though it'd prolly be easier for one of you with more experience to just go ahead and do it lol.

I'm just learning more each day, too.

Don't give up if the scripts won't work, I often run into problems, too!

Just think straight what it could be and search for missing ; and maybe syntax errors because of some { } this are the most common errors.

Also checking values of variables and datatypes can save lifes :D

http://opendayz.net/threads/project-basebuilding-1-2-change-code.10183/page-2#post-44808

Check this out how I forced the script to write the values to the .rpt file. Remember that for client side scripts it will be logged on your home pc and not on your server machine. For serverfiles it will be logged on the server machine.

Also using hints/cuttext for that is a good idea ;)
 
wait local rpt?!? where is that located by default? i've been looking at the one in my servers ftp. could be my problem there lol!
 
WOW!!! after taking a look at that i found (based off the error code) i forgot a " at the end of my cuttext message I.E. i had cutText [format["message], "PLAIN DOWN"]; notice theres no " at the end of my message WOW I FAIL HARD LOL!!! thanks a bunch!
 
Here is a example of my future Change Keycode for BaseBuilding Script. It does nearly the same what you have to do (change one field in the database of a particular item).

Cause there is no CHILD:999 custom Hive Request at the DayZ Epoch Hive (I'm using that), I had to find another solution.

I ended up in a good way to overcome all this problems. If everything is alright and the script can be started, I do a request to the database to delete the object. Then I rewrite everything to the database with same data only with my modified field.
I don't use deletevehicle cause this would cause that the object wouldn't be there till next restart. I set everything via setVariable and getVariable and for restarts just set them again at servermonitor. I used the fuel field cause this field isn't used for normal buildings ;)

In your case you need to change just Character_ID which is used to check if someones is the owner.

To restrict who can use this script I set that only owner can do this at buildables at the fn_selfactions.sqf

Here is my example script for MY case

Code:
private ["_object","_location","_dir","_worldspace","_objectID","_objectUID","_classname","_codeinput","_convertInput","_i","_stringInput","_numberInput","_fuel"];
_object = cursortarget;
_location = getposATL _object;
_dir = getDir _object;
_worldspace = [_dir,_location];
_objectID = _object getVariable["ObjectID","0"];
_objectUID = _object getVariable["ObjectUID","0"];
_classname = _object getVariable["Classname","0"];
_code = _object getVariable ["Code","0"];
//_objectUID = _worldspace call dayz_objectUID2;;
_codeinput = _this select 0;
sleep 3;
_convertInput =+ _codeinput;
for "_i" from 0 to (count _convertInput - 1) do {_convertInput set [_i, (_convertInput select _i) + 48]};
_numberInput = parseNumber (toString _convertInput);
 
 
if ( _numberInput > 10000 && _numberInput < 100000) then {
dayzDeleteObj = [_objectID,_objectUID];
publicVariableServer "dayzDeleteObj";
if (isServer) then {
dayzDeleteObj call server_deleteObj;
};
sleep 3;
_fuel = _numberInput / 100000;
_object setVariable ["characterID",dayz_playerUID,true];
dayzPublishObj = [dayz_playerUID,_object,[_dir,_location],_classname,_fuel,_code];
publicVariableServer "dayzPublishObj";
if (isServer) then {
dayzPublishObj call server_publishObj;
};
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";
};
else { cutText ["Failed to change your code, please use exact 5 numbers!", "PLAIN DOWN"];breakOut "exit";
_codeinput = [];
};
 
_codeinput = [];

I will later do complete tutorial for my BaseBuilding Improvement on my thread

http://opendayz.net/threads/project-basebuilding-1-2-change-code.10183/

Ok correct me if i'm wrong now that i have my other projects underway again i can start looking at this. basically it gets the variables listed under your desired table (in my case vehicles) then it deletes the table for said (in my case vehicle) and creates a new one adding in the extra values. Now wouldn't this require creating extra columns under my database vehicles table? or does this code do that also?
 
Nope you dont need to add new columns or fields. You will use the characterid field which is also used for ownership in tents for ecample.
In my case I added the code to the fuel field. ;)
 
I'm still a little fuzzy on how this works exactly. im not following you when you say characterid field. there is no id field under the vehicles table except for the vehicle id. which wont prove ownership?
 
Back
Top