Jump to content

Deconstruct Buildables


Snowmobil

Recommended Posts

Hi guys,

 

The below is an excerpt from remove.sqf whch includes refunding a ItemGeneric when a modular item is deconstructed.

        if(_isWreck) then {

            // Find one random part to give back

            _refundpart = ["PartEngine","PartGeneric","PartFueltank","PartWheel","PartGlass","ItemJerrycan"] call BIS_fnc_selectRandom;

            _selectedRemoveOutput set [count _selectedRemoveOutput,[_refundpart,1]];

        } else {

            if(_isWreckBuilding) then {

                _selectedRemoveOutput = getArray (configFile >> "CfgVehicles" >> _objType >> "removeoutput");

            } else {

                if(_isModularItem or _isLockableDoor) then {

                    _refundpart = ["PartGeneric"] call BIS_fnc_selectRandom;

                    _selectedRemoveOutput set [count _selectedRemoveOutput,[_refundpart,1]];                    

                } else {

                    _selectedRemoveOutput = getArray (configFile >> "CfgVehicles" >> _objType >> "removeoutput");

                    _preventRefund = (_objectID == "0" && _objectUID == "0");

                };

            

            };

        };

Anyone have a problem where the modular items return after server restart?

 

Cheers.

 

Since no refund is specified for those objects in the CfgVehicles file, you wont get any unless you create new code or another script itself to add objects to the players inventory. Cannot edit CfgVehicles without requiring client downloads, or doing some real massive work. Also if you do decide to write such a script to give a refund, make sure its exploit proof, by checking the mags of the player before and after the script, and after the object is actually deleted and removed from database, otherwise it will allow infinite item refunding like the released versions of base building 1.2 in all those server packs. Players can just refund over and over and never have to look for materials past the first acquisition, thus breaking the game balance.

Link to comment
Share on other sites

hey guys,

 

any idea how to do a script which can only be used by admins to remove abondend baes ingame ?

 

You could manually enter admin UID's into the code and where it checks if the player is the owner of the modular building item, check if they're admin too and allow the removal if they're either the owner or an admin...

That way at least an admin can remove any modular item from the game without having to find them and manually remove from the SQL.

Link to comment
Share on other sites

Hello,

 

I got a question.

When I build a wall, if I die I can't remove my wall ?

 

How can I solve this issue ?

 

If you're the server owner, then run the SQL trigger posted further up. If you're not, then convince the server owner with cookies to run the SQL trigger :)

Link to comment
Share on other sites

For sure I'm the server Owner.

I use Navicat and I created a "Querie" then I puted this code : 

 

DELIMITER ;
DROP TRIGGER IF EXISTS epoch.`update_owner`;
DELIMITER //
CREATE TRIGGER epoch.`update_owner`
AFTER INSERT ON epoch.character_data
FOR EACH ROW
BEGIN
SET @lockables = 'Classname1, Classname2, Classname3';
UPDATE epoch.object_data SET CharacterID = NEW.CharacterID WHERE FIND_IN_SET(Classname, @lockables) = 0 AND 
CharacterID IN (SELECT CharacterID FROM character_data WHERE PlayerUID = NEW.PlayerUID);
END//
DELIMITER ; 

(my database name is "epoch" and not "dayz_epoch" so I replaced "dayz_epoch" by "epoch")

 

Then I saved it and run.

I can see the CharacterID on the object_data but when I die the object (my wall) keep the old CharacterID 

 

 

Link to comment
Share on other sites

 

For sure I'm the server Owner.

I use Navicat and I created a "Querie" then I puted this code : 

 

DELIMITER ;
DROP TRIGGER IF EXISTS epoch.`update_owner`;
DELIMITER //
CREATE TRIGGER epoch.`update_owner`
AFTER INSERT ON epoch.character_data
FOR EACH ROW
BEGIN
SET @lockables = 'Classname1, Classname2, Classname3';
UPDATE epoch.object_data SET CharacterID = NEW.CharacterID WHERE FIND_IN_SET(Classname, @lockables) = 0 AND 
CharacterID IN (SELECT CharacterID FROM character_data WHERE PlayerUID = NEW.PlayerUID);
END//
DELIMITER ; 

(my database name is "epoch" and not "dayz_epoch" so I replaced "dayz_epoch" by "epoch")

 

Then I saved it and run.

I can see the CharacterID on the object_data but when I die the object (my wall) keep the old CharacterID 

 

 

 

 

Yeah I changed the database name too. It only takes effect on the next server restart though.

Link to comment
Share on other sites

Would it be possible to allow only admins to remove buildables ? I would like to allow some playerUID to have this option, I tried different things but no success.. Anyone did it ?

 

EDIT: Nevermind, got it working.. However I had to create my own script.. I guess it's because of the other scripts I am using  :mellow:

Link to comment
Share on other sites

I installed this again after 1.0.2.5 patch, but it seems to screw up the "fn_selfactions.sqf". People can't access locked vehicles anymore (just doesn't show up in the action menu anymore) same goes for name tag yes/no -> option doesn't show anymore.

 

I also noticed with the new 1.0.2.5 patch, that "remove.sqf" is now also being called within compiles.sqf. I changed it to point at the right file, but it had no effect.

 

Anyone else having these issues?

Link to comment
Share on other sites

for admins only make it look like this:

 

fn_selfactions.sqf:

	_isWreckBuilding = _typeOfCursorTarget in DZE_isWreckBuilding;
	
	_isModularItem = _cursorTarget isKindOf "ModularItems" or _cursorTarget isKindOf "Land_DZE_WoodDoor_Base" or _cursorTarget isKindOf "CinderWallDoor_DZ_Base";
	_isUnlockedDoor = (_cursorTarget isKindOf "Land_DZE_WoodDoorLocked_Base" or _cursorTarget isKindOf "CinderWallDoorLocked_DZ_Base");
	
	_isRemovable = _typeOfCursorTarget in DZE_isRemovable;
		//Allow player to delete objects
		if ((getPlayerUID player) in ["12345678"]) then { // Put in Admin PlayerIDs here
if(_isModularItem or _isUnlockedDoor) then {
				_player_deleteBuild = true;
				};
if(_isDestructable or _isWreck or _isRemovable or _isWreckBuilding) then {
				if(_hasToolbox and "ItemCrowbar" in _itemsPlayer) then {
				_player_deleteBuild = true;
				};
				};
			} else {
		if(_isDestructable or _isWreck or _isRemovable or _isWreckBuilding) then {
			if(_hasToolbox and "ItemCrowbar" in _itemsPlayer) then {
				_player_deleteBuild = true;
			};
		};
		};
		
	if(_player_deleteBuild) then {
		if (s_player_deleteBuild < 0) then {
			s_player_deleteBuild = player addAction [format[localize "str_actions_delete",_text], "Custom\remove.sqf",_cursorTarget, 1, true, true, "", ""];
		};

and remove.sqf:

_obj = _this select 3;

_activatingPlayer = player;
if ((getPlayerUID player) in ["12345678"]) then { //Put Admin Playerid here
_isOwnerOfObj = true;
} else {
_objOwnerID = _obj getVariable["CharacterID","0"];
_isOwnerOfObj = (_objOwnerID == dayz_characterID);
};

_isModularItem = _obj isKindOf "ModularItems" or _obj isKindOf "Land_DZE_WoodDoor_Base" or _obj isKindOf "CinderWallDoor_DZ_Base";
_isLockableDoor = _obj isKindOf "Land_DZE_WoodDoorLocked_Base" or _obj isKindOf "CinderWallDoorLocked_DZ_Base";
if(_isModularItem and !_isOwnerOfObj) exitWith {TradeInprogress = false; cutText ["Cannot remove item: You're not the owner.", "PLAIN DOWN"];};

if(_obj getVariable ["GeneratorRunning", false]) exitWith {TradeInprogress = false; cutText ["Cannot remove running generator.", "PLAIN DOWN"];};

This shows the remove options only to inserted admins, and lets admins remove walls even if they are not the owners. Please use this only to remove abandoned Bases i would hate people misusing that.

Link to comment
Share on other sites

DROP TRIGGER IF EXISTS update_owner;
CREATE TRIGGER update_owner
AFTER INSERT ON character_data
FOR EACH ROW
BEGIN
UPDATE object_data SET CharacterID = NEW.CharacterID WHERE CharacterID IN
(SELECT CharacterID FROM character_data WHERE PlayerUID = NEW.PlayerUID)
AND NOT (Classname LIKE '%door%' OR Classname LIKE '%vault%' OR Classname LIKE '%box%');
END

i am given the error in navicat:
[Err] 1419 - You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)

 

any solution? im using hfbservers and have already sent a ticket

 

edit: my temp solution was to recode remove.sqf to include the plot pole requirement.. all players can remove items now unless a plot pole is nearby.. plot pole can be removed by anyone.

Link to comment
Share on other sites

Since no one has managed to get returnable items from de-constructed parts, I have managed to do this myself. So far I've been working through manually and just returning the items it took to build each piece. (Slightly unrealistic I know).

This is a WIP so far and I'll be happy to release what I've written once a bit more testing has gone into it.

Has anyone got any better ways of getting returnable items from the modular parts since they don't have any pre-written tables to suggest the parts needed to construct them.

 

I've so far done most of the wooden wall/floor items, cinder walls/doors and metal floors. There are some other items that I've found to be non-removable once placed which I'd also like to take care of if possible.

Link to comment
Share on other sites

There are some other items that I've found to be non-removable once placed which I'd also like to take care of if possible.

if you mean they respawn after a restart or just dont delete use this code to delete them

_objectID = _obj getVariable ["ObjectID","0"];
_objectUID = _obj getVariable ["ObjectUID","0"];
if (isnil "server_deleteObj") then {server_deleteObj = {};};
[_obj, "killed"] spawn server_updateObject;
[_objectID,_objectUID] call server_deleteObj;
_obj removeAllMPEventHandlers "MPKilled";
_obj removeAllEventHandlers "Killed";
_obj removeAllEventHandlers "HandleDamage";
if (!isNull _obj) then {deleteVehicle _obj;};
Link to comment
Share on other sites

No, I mean for instance the 'sun shade' crafted from a canvas and lumber that has no remove option because I don't think it's part of the modular items list. Not sure what kind of list, if any, it's part of.

 

Other than that I have everything listed and the game returns parts to you for everything you deconstruct.

Link to comment
Share on other sites

In all honesty I think this is something that needs to go into the next release as a feature.  It's unrealistic to assume that if you can put up a wall that you can't take it down again.  Make it so that walls can't be broken down unless you have a sledgehammer, maybe?  I can't keep hacking my scripts with this stuff every time a new release comes out (I want to play the game too you know), so it should already be part of the mod.  I'm already looking at other mods for my server because I'm getting pissed off with listening to players moan about not being able to remove their walls etc (even I'm getting fedup on a personal level), when all the other building mods out there have this feature as standard! And why the hell are developers still using characterID's instead of UID's ? I've already asked in this forum why they do it, but didn't get an answer so I'm just going to presume its out of laziness.  Two of the other mods I'm looking at use UIDs and it seems to work perfectly for them.  

 

Anyway, just my two pence worth.   Got offline earlier after a huge argument with a clan on my server.  They'd spent days finding the parts and building this really sweet base if I'm honest, only to get a message that they've reached the limit for objects in that area.  I can't really put it any higher than 350, but maybe a warning message pops up to remind them they're getting close .. Say at 100, a message warns them they can only place another 50 objects in that area etc.. Same issue for decay, when you've got a building made up of hundreds of pieces, some of which are days apart, how the fack are you supposed to know which ones actually do need upgrading, as the message to upgrade pops up even on walls that have just been laid.  If you don't keep up you log in one day to find your wall(s) vanished.  So now they expect me as admin to have some magic power to clear it all for them and they think I'm lying when I tell them this mod doesn't allow you to remove parts and going through the database for a 350 piece building will take me hours... fml! 

 

Peace out.

Link to comment
Share on other sites

In all honesty I think this is something that needs to go into the next release as a feature.  It's unrealistic to assume that if you can put up a wall that you can't take it down again.  Make it so that walls can't be broken down unless you have a sledgehammer, maybe?  I can't keep hacking my scripts with this stuff every time a new release comes out (I want to play the game too you know), so it should already be part of the mod.  I'm already looking at other mods for my server because I'm getting pissed off with listening to players moan about not being able to remove their walls etc (even I'm getting fedup on a personal level), when all the other building mods out there have this feature as standard! And why the hell are developers still using characterID's instead of UID's ? I've already asked in this forum why they do it, but didn't get an answer so I'm just going to presume its out of laziness.  Two of the other mods I'm looking at use UIDs and it seems to work perfectly for them.  

 

Anyway, just my two pence worth.   Got offline earlier after a huge argument with a clan on my server.  They'd spent days finding the parts and building this really sweet base if I'm honest, only to get a message that they've reached the limit for objects in that area.  I can't really put it any higher than 350, but maybe a warning message pops up to remind them they're getting close .. Say at 100, a message warns them they can only place another 50 objects in that area etc.. Same issue for decay, when you've got a building made up of hundreds of pieces, some of which are days apart, how the fack are you supposed to know which ones actually do need upgrading, as the message to upgrade pops up even on walls that have just been laid.  If you don't keep up you log in one day to find your wall(s) vanished.  So now they expect me as admin to have some magic power to clear it all for them and they think I'm lying when I tell them this mod doesn't allow you to remove parts and going through the database for a 350 piece building will take me hours... fml! 

 

Peace out.

 

I would have to agree with you. The base building is a nice feature, but its far from finished.

I removed the decay from my server, and I increased the building limit as well so I don't have these problems, it's just that certain things need to be hacked in all the time to make things worth while. Now I've spent about an hour adding in the returning of parts for deconstruction I feel that the base building is slightly more complete than it has been for a while.

 

Hopefully more useful mods are added in with the option to enable/disable them in the future to allow Epoch to become the most complete build of DayZ!

Link to comment
Share on other sites

Hey waTTe, love your work thanks. I cant seem to get it to work. I get the option to remove an object but it doesn't do anything.

 

 

 

Never mind, I found my error. Works Perfectly! Many thanks and again love your work.

 

I have same issue but i cant find my error 

 

EDIT: NVM FIXED it

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
×
×
  • Create New...