Home   Help Search Login Register  

Author Topic: Land based Wrecker  (Read 1653 times)

0 Members and 1 Guest are viewing this topic.

Offline fallujahmedic

  • Members
  • *
Land based Wrecker
« on: 28 Jan 2009, 21:58:35 »
 As opposed to an air based Wrecker (MI or Chinook (A.C.E)) is it possible to make a land based (vehicle) as a wrecker. Say drive a "special" service vehicle next to the wreck and around the vehicle (when stopped) there is a radius in which wrecks will be rebuilt?
 If yes, the difficult question is how?

Also flipped vehicles, must it be linked to a repair truck to unflip a vehicle or can a script be written to allow an engineer to do it? We plan on locking tasks to positions (ie an AA soldier doesnt know how to fly, etc). And again, how?

Yes, I searched  :dry:

Offline Rommel92

  • Members
  • *
Re: Land based Wrecker
« Reply #1 on: 31 Jan 2009, 23:29:44 »
Well I assume you mean some sort of salvage/repair vehicle; in any case you could just have a script set-up similarly to this code snippet:

Code: (ROMM_wrecker.sqf) [Select]
//run via init line in the editor (excuse this scripts cruddyness, it will need a lot of testing)

private"_w"; //depending on execution, this may or may not be needed
_w = _this select 0; //wrecker vehicle

while {canMove _w AND alive _w} do {
sleep 3;
private"_v"
_v = nearestObject [_w, "LandVehicle"];
if (NOT alive _v) then {
(driver _w) groupchat format ["%1, Salvaging nearBy %2 wreck; move your vehicle to cancel", name (driver _w), typeOf _v];
private"_p";
_p = position _v;
private"_t";
_t = typeof _v;
private"_i";
_i = 0;
while {_i < 30} do {
_i = _i + 1;
if (speed _w > 0) exitwith {(driver _w) groupchat format ["%1, Salvaging nearBy %2 wreck: cancelled", name (driver _w), _t];};
if (_i == 29)then{
deletevehicle _v;
_t createVehicle _p;
(driver _w) groupchat format ["%1, Salvaging nearBy %2 wreck: complete", name (driver _w), _t];
};
};
};
};

Quote
We plan on locking tasks to positions (ie an AA soldier doesnt know how to fly, etc). And again, how?

Yes, I searched  Dry

Check BAS f;

OR

Code: (ROMM_authorisedCrewCheck.sqf) [Select]
/*author(s): rommel
23-01-2009 */

#include "f_waitforjip.h"

private ["_vehicle", "_role", "_type", "_unit", "_crew"];

_vehicle = (_this select 0);
_role = (_this select 1);
_unit = (_this select 2);
_crew = [];

if (_vehicle isKindof "Tank") then {
_crew = [S1,S2,S3,S4,S5,S6] //Unit names (set in editor) who can use this vehicle;
};
if (_vehicle isKindof "Car") then {
_crew = [S1] //Unit names (set in editor) who can use this vehicle;
};
if (_vehicle isKindof "Ship") then {
_crew = [S4,S6] //Unit names (set in editor) who can use this vehicle;
};
if (_vehicle isKindof "Air") then {
_crew = [S1,S2,S3,S4,S5,S6] //Unit names (set in editor) who can use this vehicle;
};

if (_vehicle iskindof "Motorcycle") then {
_crew = [S1,S2,S3,S4,S5,S6] //Unit names (set in editor) who can use this vehicle;
};

if (isPlayer _unit) then {
if ((_role != "cargo") and (!(_unit in _crew))) then {
_unit action ["getout", _vehicle];
}else{
if(_role == "cargo" and (!(_unit in _crew))) then {
[_unit,_vehicle] spawn {
private ["_unit","_vehicle"];

_unit = _this select 0;
_vehicle = _this select 1;
while {_unit in crew _vehicle} do
{
if (commander _vehicle == _unit) exitWith {};
if (driver _vehicle == _unit) exitWith {};
if (gunner _vehicle == _unit) exitWith {};
sleep 1;
};
_unit action ["getout", _vehicle];
};
};
};
};

Run via the init.sqf with the following code:
Code: [Select]
[] spawn
{
private"_f_list";
_f_list = createTrigger ["EmptyDetector", [12500, 12500, 0]];
_f_list setTriggerArea [20000, 200000, 0, false];
_f_list setTriggerActivation ["ANY", "PRESENT", true];
_f_list setTriggerStatements ["this", "", ""];
waitUntil {time > 2};
{
if (not (_x iskindof "man") and not (_x iskindof "static") and not (_x iskindof "thing")) then {
_x addEventhandler ["GetIn", {_this execVM "ROMM_authorisedCrewCheck.sqf"}];
}
} foreach list _f_list;
};
« Last Edit: 31 Jan 2009, 23:41:05 by Rommel92 »

Offline Landdon

  • Members
  • *
Re: Land based Wrecker
« Reply #2 on: 01 Feb 2009, 00:40:33 »
How did you run it from the Init Line of the vehicle in the editor?

Offline Rommel92

  • Members
  • *
Re: Land based Wrecker
« Reply #3 on: 01 Feb 2009, 00:43:12 »
If your referring to the vehicleAuthorisation script; simply place the code provided for the init.sqf, and all that is needed to be done, is done.  ;)

ELSE

For the wrecker script:

nul=[this]exec"ROMM_wrecker.sqf";

Offline Landdon

  • Members
  • *
Re: Land based Wrecker
« Reply #4 on: 01 Feb 2009, 04:05:44 »
I must be doing something wrong then, because I get the following error:

Type Nothing, expected Any

Once I put it into my "Initialization Line" of the repair truck that I want to make my wrecker.

Offline Rommel92

  • Members
  • *
Re: Land based Wrecker
« Reply #5 on: 01 Feb 2009, 04:55:35 »
Sorry, I was busy doing homework.  ;)

Just tested, fixed the errors and got it working for you beautifully (atleast as far as your needs have specified).
Code: (ROMM_salvage.sqf) [Select]
//run via init line in the editor (excuse this scripts cruddyness, it will need a lot of testing)

private"_w"; //depending on execution, this may or may not be needed
_w = _this select 0; //wrecker vehicle

private"_debug";
_debug = 0; //set to 1 to enable;

if(_debug == 1)then{(driver _w) groupchat format ["%1", [canMove _w AND alive _w]]};

while {canMove _w AND alive _w} do {
sleep 3;
private"_v";
_v = nearestObjects [_w, ["Car","Truck","Tank","Air"], 100];

if(_debug == 1)then{(driver _w) groupchat format ["%1, nearby Wrecks %2", name (driver _w), _v]};
{
if (_w distance _x < 30) then {
if (NOT alive _x) then {

if(_debug == 1)then{(driver _w) groupchat format ["%1, Salvaging nearBy %2 wreck; move your vehicle to cancel", name (driver _w), typeOf _x]};

private"_p";
_p = position _x;
private"_t";
_t = typeof _x;
private"_i";
_i = 0;

while {_i < 30} do { //CHANGE THIS NUMBER TO DELAY IN SECONDS FOR HOW LONG IT TAKES TO REPAIR!!!
_i = _i + 1;

if (speed _w > 0) exitwith {if(_debug == 1)then{(driver _w) groupchat format ["%1, Salvaging nearBy %2 wreck: cancelled", name (driver _w), _t]}};

if (_i == 29)then{
deletevehicle _x;
_t createVehicle _p;

if(_debug == 1)then{(driver _w) groupchat format ["%1, Salvaging nearBy %2 wreck: complete", name (driver _w), _t]};
};
};
};
};
}foreach _v;
};

removed script before this to avoid confusion.
« Last Edit: 01 Feb 2009, 04:57:34 by Rommel92 »

Offline Landdon

  • Members
  • *
Re: Land based Wrecker
« Reply #6 on: 01 Feb 2009, 20:14:39 »
Thanks! :good: