IRONFRONT FANS FORUM
Register Latest Topics
 
 
 


Reply
  Author   Comment  
Tayuk

Avatar / Picture

Admin
Registered:
Posts: 455
Reply with quote  #1 

Download: Vehicle Re-arm, Re-fuel and Repair

This is a nice script from Xeno that creates a vehicle re-arm and repair point. You drive your vehicle to the point marked on the map (within a trigger area) and your vehicle will re-arm, re-fuel and repair.

Place a trigger of size whatever you want (10x10 or 15x15 are good sizes for this) where you want the repair point.
Set it for anybody present and set if for repeatadly
In the trigger condition box put this

Code:
this and ((getpos (thislist select 0)) select 2 < 1)

And in the On Activation box put this
Code:
_xhandle= [(thislist select 0)] execVM "x_reload.sqf";


Then put this file called "x_reload.sqf" in your mission folder
Code:

// by Xeno

private ["_config","_count","_i","_magazines","_object","_type","_type_name"];

_object = _this select 0;

_type = typeof _object;

if (_object isKindOf "ParachuteBase") exitWith {};

if (isNil "x_reload_time_factor") then {x_reload_time_factor = 1;};

//if (!local _object) exitWith {};

if (!alive _object) exitWith {};

_object setFuel 0;

_object setVehicleAmmo 1; // Reload turrets / drivers magazine

_type_name = typeOf _object;

_object vehicleChat format ["Servicing %1... Please stand by...", _type];

_magazines = getArray(configFile >> "CfgVehicles" >> _type >> "magazines");

if (count _magazines > 0) then {

_removed = [];

{

if (!(_x in _removed)) then {

_object removeMagazines _x;

_removed set [count _removed, _x];

};

} forEach _magazines;

{

_object vehicleChat format ["Reloading %1", _x];

sleep x_reload_time_factor;

if (!alive _object) exitWith {};

_object addMagazine _x;

} forEach _magazines;

};

_count = count (configFile >> "CfgVehicles" >> _type >> "Turrets");

if (_count > 0) then {

for "_i" from 0 to (_count - 1) do {

scopeName "xx_reload2_xx";

_config = (configFile >> "CfgVehicles" >> _type >> "Turrets") select _i;

_magazines = getArray(_config >> "magazines");

_removed = [];

{

if (!(_x in _removed)) then {

_object removeMagazines _x;

_removed set [count _removed, _x];

};

} forEach _magazines;

{

_object vehicleChat format ["Reloading %1", _x];

sleep x_reload_time_factor;

if (!alive _object) then {breakOut "xx_reload2_xx"};

_object addMagazine _x;

sleep x_reload_time_factor;

if (!alive _object) then {breakOut "xx_reload2_xx"};

} forEach _magazines;

// check if the main turret has other turrets

_count_other = count (_config >> "Turrets");

// this code doesn't work, it's not possible to load turrets that are part of another turret

// nevertheless, I leave it here

if (_count_other > 0) then {

for "_i" from 0 to (_count_other - 1) do {

_config2 = (_config >> "Turrets") select _i;

_magazines = getArray(_config2 >> "magazines");

_removed = [];

{

if (!(_x in _removed)) then {

_object removeMagazines _x;

_removed set [count _removed, _x];

};

} forEach _magazines;

{

_object vehicleChat format ["Reloading %1", _x];

sleep x_reload_time_factor;

if (!alive _object) then {breakOut "xx_reload2_xx"};

_object addMagazine _x;

sleep x_reload_time_factor;

if (!alive _object) then {breakOut "xx_reload2_xx"};

} forEach _magazines;

};

};

};

};

_object setVehicleAmmo 1; // Reload turrets / drivers magazine

sleep x_reload_time_factor;

if (!alive _object) exitWith {};

_object vehicleChat "Repairing...";

_object setDamage 0;

sleep x_reload_time_factor;

if (!alive _object) exitWith {};

_object vehicleChat "Refueling...";

while {fuel _object < 0.99} do {

//_object setFuel ((fuel _vehicle + 0.1) min 1);

_object setFuel 1;

sleep 0.01;

};

sleep x_reload_time_factor;

if (!alive _object) exitWith {};

_object vehicleChat format ["%1 is ready...", _type_name];

if (true) exitWith {};


 

0
Joarius

Avatar / Picture

IFR Team
Registered:
Posts: 290
Reply with quote  #2 
I'm not a specialist in scripts, and i see that there is spaces beetween the lines. Is it normal ?
__________________
0
Tayuk

Avatar / Picture

Admin
Registered:
Posts: 455
Reply with quote  #3 
No, spaces can be got rid of if you wish, but they shouldn't effect the script, for some reason copy and pasting the script puts extra empty lines in.
0
Gunter Severloh

Avatar / Picture

Admin
Registered:
Posts: 2,733
Reply with quote  #4 
Script is now hosted on the MR, readme included, link added to the first post for download.
__________________
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.