HX3 Foren

HX3 Foren (https://hx3.de/)
-   Editing & Scripting (https://hx3.de/editing-scripting-167/)
-   -   mhq respawn (https://hx3.de/editing-scripting-167/mhq-respawn-22699/)

McLaine 01.07.2013 00:56

mhq respawn
 
hallo zusammen

ich würde gerne mein mhq respawnen wenn es zerstört wurde. möglichst ohne zeitverzug.

habe das script gefunden.

leider läst es auch mein mhq verschwinden sobald der timer abgelaufen ist.
das soll eigentlich nur sein wenn es wiegesagt zerstört wurde.


Zitat:

================================================== =======
*/

if (!isServer) exitWith {};

// Define variables
_unit = _this select 0;
_delay = if (count _this > 1) then {_this select 1} else {30};
_deserted = if (count _this > 2) then {_this select 2} else {120};
_respawns = if (count _this > 3) then {_this select 3} else {0};
_explode = if (count _this > 4) then {_this select 4} else {false};
_dynamic = if (count _this > 5) then {_this select 5} else {false};
_unitinit = if (count _this > 6) then {_this select 6} else {};
_haveinit = if (count _this > 6) then {true} else {false};

_hasname = false;
_unitname = vehicleVarName _unit;
if (isNil _unitname) then {_hasname = false;} else {_hasname = true;};
_noend = true;
_run = true;
_rounds = 0;

if (_delay < 0) then {_delay = 0};
if (_deserted < 0) then {_deserted = 0};
if (_respawns <= 0) then {_respawns= 0; _noend = true;};
if (_respawns > 0) then {_noend = false};

_dir = getDir _unit;
_position = getPosASL _unit;
_type = typeOf _unit;
_dead = false;
_nodelay = false;


// Start monitoring the vehicle
while {_run} do
{
sleep (2 + random 10);
if ((getDammage _unit > 0.8) and ({alive _x} count crew _unit == 0)) then {_dead = true};

// Check if the vehicle is deserted.
if (_deserted > 0) then
{
if ((getPosASL _unit distance _position > 10) and ({alive _x} count crew _unit == 0) and (getDammage _unit < 0.8)) then
{
_timeout = time + _deserted;
sleep 0.1;
waitUntil {_timeout < time or !alive _unit or {alive _x} count crew _unit > 0};
if ({alive _x} count crew _unit > 0) then {_dead = false};
if ({alive _x} count crew _unit == 0) then {_dead = true; _nodelay =true};
if !(alive _unit) then {_dead = true; _nodelay = false};
};
};

// Respawn vehicle
if (_dead) then
{
if (_nodelay) then {sleep 0.1; _nodelay = false;} else {sleep _delay;};
if (_dynamic) then {_position = getPosASL _unit; _dir = getDir _unit;};
if (_explode) then {_effect = "M_TOW_AT" createVehicle getPosASL _unit; _effect setPosASL getPosASL _unit;};
sleep 0.1;

deleteVehicle _unit;
sleep 2;
_unit = _type createVehicle _position;
_unit setPosASL _position;
_unit setDir _dir;

if (_haveinit) then
{_unit setVehicleInit format ["%1;", _unitinit];
processInitCommands;};
if (_hasname) then
{_unit setVehicleInit format ["%1 = this; this setVehicleVarName ""%1""",_unitname];
processInitCommands;};
_dead = false;

// Check respawn amount
if !(_noend) then {_rounds = _rounds + 1};
if ((_rounds == _respawns) and !(_noend)) then {_run = false;};
};
};

Vienna 01.07.2013 10:26

Dieser Teil des Codes scheint mir für das Beenden des Skripts verantwortlich zu sein:

Code:

// Check if the vehicle is deserted.
if (_deserted > 0) then
 {
  if ((getPosASL _unit distance _position > 10) and ({alive _x} count crew _unit == 0) and (getDammage _unit < 0.8)) then
  {
    _timeout = time + _deserted;
    sleep 0.1;
    waitUntil {_timeout < time or !alive _unit or {alive _x} count crew _unit > 0};
    if ({alive _x} count crew _unit > 0) then {_dead = false};
    if ({alive _x} count crew _unit == 0) then {_dead = true; _nodelay =true};
    if !(alive _unit) then {_dead = true; _nodelay = false};
  };
 };

// Respawn vehicle
if (_dead) then
...

Stelle vor die fette Codezeile die Kommentarzeichen // dann ist diese Zeile deaktiviert. Sie entfernt die Unit nach dem Timeout wenn sie nicht besetzt ist.


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:31 Uhr.

Angetrieben durch vBulletin, Entwicklung von Philipp Dörner & Tobias


SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119