Jump to content

[Release] Vehicle Service Point (Refuel, Repair, Rearm) [Script]


Axe Cop

Recommended Posts

@Liquid84 I had my players test it more. It seems I (being an admin) can do it just fine. I see an error pop up in the .rpt when I do it, but it lets me anyways. My players on the other hand report differently, saying they can not even repair it at all. But it was an admin who told me his car kept reverting to back before it was healed.

 

The error was something about line 49 and mentioned "call object_setFixServer". I use the show logs on DayZ Launcher so I saw that pop up for a moment.

 

Link to comment
Share on other sites

// Vehicle Service Point (Repair) by Axe Cop

private ["_vehicle","_args","_servicePoint","_costs","_repairTime","_type","_name","_hitpoints","_allRepaired","_textMissing","_selection","_strH"];

_vehicle = _this select 0;
if (!local _vehicle) exitWith { diag_log format["Error: called service_point_repair.sqf with non-local vehicle: %1", _vehicle] };

_args = _this select 3;
_servicePoint = _args select 0;
_costs = _args select 1;
_repairTime = _args select 2;

//if !([_costs] call player_checkAndRemoveItems) exitWith {};
if !([[[_costs select 0, _costs select 1]],0] call epoch_returnChange) then {
	_textMissing = getText(configFile >> "CfgMagazines" >> _costs select 0 >> "displayName");
	cutText [format[(localize "STR_EPOCH_ACTIONS_12"), _costs select 1, _textMissing], "PLAIN DOWN"];
} else {

	_type = typeOf _vehicle;
	_name = getText(configFile >> "cfgVehicles" >> _type >> "displayName");
	
	_vehicle engineOn false;
	[_vehicle,"repair",0,false] call dayz_zombieSpeak;
	
	_hitpoints = _vehicle call vehicle_getHitpoints;
	_allRepaired = true;
	{
		private ["_damage","_selection"];
		if ((vehicle player != _vehicle) || (!local _vehicle) || ([0,0,0] distance (velocity _vehicle) > 1)) exitWith {
			_allRepaired = false;
			titleText [format["Repairing of %1 stopped", _name], "PLAIN DOWN"];
		};
		_damage = [_vehicle,_x] call object_getHit;
		if (_damage > 0) then {
			if (_repairTime > 0) then {
				private "_partName";
				//change "HitPart" to " - Part" rather than complicated string replace
				_partName = toArray _x;
				_partName set [0,20];
				_partName set [1,45];
				_partName set [2,20];
				_partName = toString _partName;
				titleText [format["Repairing%1 ...", _partName], "PLAIN DOWN", _repairTime];
				
				_selection = getText(configFile >> "cfgVehicles" >> _type >> "HitPoints" >> _x >> "name");				
				_strH = "hit_" + (_selection);
				_vehicle setHit[_selection,0];
				_vehicle setVariable [_strH,0,true];				
				sleep _repairTime;
			};
		};
	} forEach _hitpoints;
	
	PVDZ_veh_Save = [_vehicle,"repair"]; 
	publicVariableServer "PVDZ_veh_Save";
	
	if (_allRepaired) then {
		_vehicle setDamage 0;
		_vehicle setVelocity [0,0,1];
		titleText [format["%1 Repaired", _name], "PLAIN DOWN"];
	};
};

If you replace your service_point_repair.sqf with this file it will correctly update the repair script to work correctly with 1.0.6.

It is tested and does save to the database.

Link to comment
Share on other sites

1 hour ago, salival said:

// Vehicle Service Point (Repair) by Axe Cop

private ["_vehicle","_args","_servicePoint","_costs","_repairTime","_type","_name","_hitpoints","_allRepaired","_textMissing","_selection","_strH"];

_vehicle = _this select 0;
if (!local _vehicle) exitWith { diag_log format["Error: called service_point_repair.sqf with non-local vehicle: %1", _vehicle] };

_args = _this select 3;
_servicePoint = _args select 0;
_costs = _args select 1;
_repairTime = _args select 2;

//if !([_costs] call player_checkAndRemoveItems) exitWith {};
if !([[[_costs select 0, _costs select 1]],0] call epoch_returnChange) then {
	_textMissing = getText(configFile >> "CfgMagazines" >> _costs select 0 >> "displayName");
	cutText [format[(localize "STR_EPOCH_ACTIONS_12"), _costs select 1, _textMissing], "PLAIN DOWN"];
} else {

	_type = typeOf _vehicle;
	_name = getText(configFile >> "cfgVehicles" >> _type >> "displayName");
	
	_vehicle engineOn false;
	[_vehicle,"repair",0,false] call dayz_zombieSpeak;
	
	_hitpoints = _vehicle call vehicle_getHitpoints;
	_allRepaired = true;
	{
		private ["_damage","_selection"];
		if ((vehicle player != _vehicle) || (!local _vehicle) || ([0,0,0] distance (velocity _vehicle) > 1)) exitWith {
			_allRepaired = false;
			titleText [format["Repairing of %1 stopped", _name], "PLAIN DOWN"];
		};
		_damage = [_vehicle,_x] call object_getHit;
		if (_damage > 0) then {
			if (_repairTime > 0) then {
				private "_partName";
				//change "HitPart" to " - Part" rather than complicated string replace
				_partName = toArray _x;
				_partName set [0,20];
				_partName set [1,45];
				_partName set [2,20];
				_partName = toString _partName;
				titleText [format["Repairing%1 ...", _partName], "PLAIN DOWN", _repairTime];
				
				_selection = getText(configFile >> "cfgVehicles" >> _type >> "HitPoints" >> _x >> "name");				
				_strH = "hit_" + (_selection);
				_vehicle setHit[_selection,0];
				_vehicle setVariable [_strH,0,true];				
				sleep _repairTime;
			};
		};
	} forEach _hitpoints;
	
	PVDZ_veh_Save = [_vehicle,"repair"]; 
	publicVariableServer "PVDZ_veh_Save";
	
	if (_allRepaired) then {
		_vehicle setDamage 0;
		_vehicle setVelocity [0,0,1];
		titleText [format["%1 Repaired", _name], "PLAIN DOWN"];
	};
};

This will correctly update the repair script to work correctly with 1.0.6.

Is tested and does save to the database.

More amazing fixes from @salival!!!

Link to comment
Share on other sites

7 hours ago, looter809 said:

Actually, I think I found out why it was not working. I'm sure your fix works, but I see now what was wrong with the old version.

On https://github.com/EpochModTeam/DayZ-Epoch/blob/master/Documents/1.0.6 Variable Name Changes.txt

- object_setFixServer --> fnc_veh_setFixServer

 


		if (_damage > 0) then {
			if (_repairTime > 0) then {
				private "_partName";
				//change "HitPart" to " - Part" rather than complicated string replace
				_partName = toArray _x;
				_partName set [0,20];
				_partName set [1,45];
				_partName set [2,20];
				_partName = toString _partName;
				titleText [format["Repairing%1 ...", _partName], "PLAIN DOWN", _repairTime];
				sleep _repairTime;
			};
			_selection = getText(configFile >> "cfgVehicles" >> _type >> "HitPoints" >> _x >> "name");
			[_vehicle,_selection,0] call fnc_veh_setFixServer;
		};
	} forEach _hitpoints;

 

 

 

This is why it was not working. I haven't tested my fix yet, but I think this should fix it...

Thanks anyways for the help.

Just changing this variable from object_setFixServer to fnc_veh_setFixServer won't fix it in this case since now, fnc_veh_setFixServer has been moved to server side compiles and is designed for server side use only.

The previous function object_setFixServer was client AND serverside, my fix uses the code from the new fnc_veh_setFixServer but transmits it from the client.

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...