Technical > Editing & Coding

delete object after action

(1/4) > >>

GriffinZS:
This is my little changes of the repair script:


--- Code: ---// ******************************************************************************************
// * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com *
// ******************************************************************************************
//@file Version: 1.0
//@file Name: repair.sqf
//@file Author: MercyfulFate
//@file Created: 23/7/2013 16:00
//@file Description: Repair the nearest Vehicle

#define DURATION 20
#define REPAIR_RANGE 6;
#define ANIMATION "Acts_carFixingWheel"
#define ERR_NO_VEHICLE "You are not close enough to a vehicle that needs repairing"
#define ERR_IN_VEHICLE "Repairing Failed! You can't do that in a vehicle"
#define ERR_FULL_HEALTH "Repairing Failed! The vehicle is already repaired"
#define ERR_DESTROYED "The vehicle is too damaged to repair"
#define ERR_TOO_FAR_AWAY "Repairing failed! You moved too far away from the vehicle"
#define ERR_CANCELLED "Repairing cancelled!"

private ["_vehicle", "_hitPoints", "_checks", "_success", "_repaircase"];
_vehicle = call mf_repair_nearest_vehicle;
_hitPoints = (typeOf _vehicle) call getHitPoints;

_checks = {
private ["_progress","_failed", "_text"];
_progress = _this select 0;
_vehicle = _this select 1;
_text = "";
_failed = true;
switch (true) do {
case (!alive player): {}; // player is dead, no need for a notification
case (vehicle player != player): {_text = ERR_IN_VEHICLE};
case (player distance _vehicle > (sizeOf typeOf _vehicle / 3) max 2): {_text = ERR_TOO_FAR_AWAY};
case (!alive _vehicle): {_text = ERR_DESTROYED};
case (damage _vehicle < 0.05 && {{_vehicle getHitPointDamage (configName _x) > 0.05} count _hitPoints == 0}): {_text = ERR_FULL_HEALTH}; // 0.2 is the threshold at which wheel damage causes slower movement
case (doCancelAction): {_text = ERR_CANCELLED; doCancelAction = false;};
default {
_text = format["Repairing %1%2 Complete", round(100 * _progress), "%"];
_failed = false;

_repaircase = "Land_PlasticCase_01_small_black_F" createVehicle position player;
_repaircase setposatl (player modelToWorld [0.55,-0.2,0]);
_repaircase setdir (getdir player +10);
_repaircase setpos [(getpos _repaircase) select 0,(getpos _repaircase) select 1, 0.1];
_repaircase setVectorUp surfaceNormal position _repaircase;
_repaircase enableSimulation false;



};
};
[_failed, _text];

};
_success = [DURATION, ANIMATION, _checks, [_vehicle]] call a3w_actions_start;

if (_success) then {
[netId _vehicle] remoteExec ["mf_remote_repair", _vehicle];
["Repairing complete!", 5] call mf_notify_client;

};

_success;

--- End code ---


Not only changed the silver suitcase, also this new box is placed next to the player while repairing.

One problem: after repair is done, I want this box to disappear. Tried several things with deleteVehicle _repaircase; but failed.

-TheBigTom-:

--- Quote from: GriffinZS on Nov 06, 2022, 10:21 PM ---.

--- End quote ---

have you even tried "nearestobject"??
something like



--- Code: ---_
successExec = {
// repair complete
_baseToDelete = player nearObjects ["Land_PlasticCase_01_small_black_F", 5];
        { deleteVehicle _x } forEach _baseToDelete;


--- End code ---

I used something simillar with misson where i put mines around the mission and after mission they didnt wanted to be deleted, so i had to add this to delete them after mission ended


LeonZ:
Yes and no, yes to use nearestObject and that is not mission, i assume your mission have some error inside so you search it, the only solution is use your method

GriffinZS:

--- Quote from: -TheBigTom- on Nov 07, 2022, 02:51 PM ---have you even tried "nearestobject"??
something like



--- Code: ---_
successExec = {
// repair complete
_baseToDelete = player nearObjects ["Land_PlasticCase_01_small_black_F", 5];
        { deleteVehicle _x } forEach _baseToDelete;


--- End code ---

I used something simillar with misson where i put mines around the mission and after mission they didnt wanted to be deleted, so i had to add this to delete them after mission ended

--- End quote ---

will try. thx

-TheBigTom-:
np mate, let us know later if that worked or not :) Kinda like that idea tbh

Navigation

[0] Message Index

[#] Next page

Go to full version