naong 1 Posted May 3, 2013 I modified script and tested in 0.56 stable. If you you want to set the INIT field of the respawned vehicle, first set all other values, then set init commands. Those must be inside quotations. Like this: veh = [this, 15, 10, 5, TRUE, FALSE, "_this setDamage 0.5;"] execVM "vehicle.sqf" not 'this' but '_this' /////////////////////////////////// // Simple Vehicle Respawn Script v1.81 for Arma 3 // by Tophe of Östgöta Ops [OOPS] 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_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; // Modified by naong if (_haveinit) then { //_unit setVehicleInit format ["%1;", _unitinit]; //processInitCommands; private ["_sTempText", "_sCommand"]; _sTempText = "call compile format['%1',"; _sCommand = format["[{(objectFromNetID '%1') %2 '%3'];}]", netID _unit, _sTempText, _unitinit]; [call compile format["%1",_sCommand], "BIS_fnc_spawn", true, true] spawn BIS_fnc_MP; }; if (_hasname) then { //_unit setVehicleInit format ["%1 = this; this setVehicleVarName ""%1""",_unitname]; //processInitCommands; private "_sCommand"; _sCommand = format["[{(objectFromNetID '%1') setVehicleVarName '%2';}]", netID _unit, _unitname]; [call compile format["%1",_sCommand],"BIS_fnc_spawn", true, true] spawn BIS_fnc_MP; _unit call compile format ["%1=_This; PublicVariable '%1'",_unitname]; }; _dead = false; //////////////////// // Check respawn amount if !(_noend) then {_rounds = _rounds + 1}; if ((_rounds == _respawns) and !(_noend)) then {_run = false;}; }; }; Share this post Link to post Share on other sites
Harzach 2517 Posted May 3, 2013 Nicely done, naong. Share this post Link to post Share on other sites
Twix 1 Posted May 3, 2013 new version works perfectly so far, cheers. Share this post Link to post Share on other sites
chal00 12 Posted May 3, 2013 (edited) Not for me!! I don't understand, since the v 1.7, each time i destroy an assault boat, i can't drive it or get in, when it respawn!!... I need a "repair specialist" to repair it before we can use it another time! Why? P.S : http://feedback.arma3.com/view.php?id=7718#bugnotes ---------- Post added at 18:06 ---------- Previous post was at 18:05 ---------- And now, since yesterday, i have this message when i launch my game (with @acre, @R3f, @sthud, @cba_a3...) : http://steamcommunity.com/sharedfiles/filedetails/?id=143014163 http://steamcommunity.com/sharedfiles/filedetails/?id=143014213 http://steamcommunity.com/sharedfiles/filedetails/?id=143014278 Thanks all because i don't understand why! :( Edited May 3, 2013 by chal00 Share this post Link to post Share on other sites
Twix 1 Posted May 3, 2013 Chal00, passe sur TS on en discute :) Share this post Link to post Share on other sites
lordprimate 159 Posted May 3, 2013 Not for me!!I don't understand, since the v 1.7, each time i destroy an assault boat, i can't drive it or get in, when it respawn!!... I need a "repair specialist" to repair it before we can use it another time! Why? P.S : http://feedback.arma3.com/view.php?id=7718#bugnotes ---------- Post added at 18:06 ---------- Previous post was at 18:05 ---------- And now, since yesterday, i have this message when i launch my game (with @acre, @R3f, @sthud, @cba_a3...) : http://steamcommunity.com/sharedfiles/filedetails/?id=143014163 http://steamcommunity.com/sharedfiles/filedetails/?id=143014213 http://steamcommunity.com/sharedfiles/filedetails/?id=143014278 Thanks all because i don't understand why! :( I can tell you what is obvious... The script errors you are seeing are From CBA... the path is actually in the error if you look at it.. it tells you what the error is, and where it is.... This will be taken care of when the CBA team fixes it. Until then you have to deal... Share this post Link to post Share on other sites
KevsNoTrev 44 Posted May 3, 2013 Thanks all because i don't understand why! :( In the latest stable release -showscripterrors is now on by default. People who have never used this parameter before at launch are not sure what they are seeing. Given it tells you the filename, location and line number to fix it makes bug testing very simple. Not sure if that's what you meant... Share this post Link to post Share on other sites
chal00 12 Posted May 3, 2013 Ok thanks, i finally understood that for the CBA ^^ But for the respawn problem = no :( I have this problem since the first game version, and since the v1.7 until v1.81 of vehicle respawn script, as i shown! Someone can tell me why i can't use assault boat after they respawn?? P.S : i tried naong's script, and it's same thing for me !! Can you try it on assaul boat (in water) to tell me! thx ;) Share this post Link to post Share on other sites
f2k sel 164 Posted May 3, 2013 Didn't this script work in both SP and MP mode but now with the removal of setVehicleInit it will only work in MP using naongs update or am I missing something. Share this post Link to post Share on other sites
SpaydCBR 11 Posted May 3, 2013 I can't get this script to work. I downloaded it off armaholic. I tried the test mission that came with it but it wasn't working. I destroyed both Hunters in the mission and waited a few minutes but nothing happened. I then tried my own mission, placed a player and empty hunter, i put veh = [this] execVM "vehicle.sqf" in the vehicle's init, and made sure the vehicle.sqf script was in the mission folder. Again, nothing happens when I blow it up. Is there something I'm missing? Share this post Link to post Share on other sites
chal00 12 Posted May 5, 2013 (edited) Ok i return!!... i tried all i can do! And now i know exactly the problem with this script! This script (naong's script with the 0.56 game version) is good to have a respawn vehicle, and has no bug! But there's still a problem : When you're not the leader (of your squad/group), you can't drive or get in assault boat/vehicle, if your vehicle isn't "unlocked"! The problem is that, when the vehicle respawn, it's not "unlocked" anymore!!.. Then you cannot drive it if you're not leader! What can i do for that? Is there a problem with the respawn? Thx ! Edited May 5, 2013 by chal00 Share this post Link to post Share on other sites
SpaydCBR 11 Posted May 5, 2013 Ok i return!!... i tried all i can do! And now i know exactly the problem with this script!This script (naong's script with the 0.56 game version) is good to have a respawn vehicle, and has no bug! But there's still a problem : When you're not the leader (of your squad/group), you can't drive or get in assault boat/vehicle, if your vehicle isn't "unlocked"! The problem is that, when the vehicle respawn, it's not "unlocked" anymore!!.. Then you cannot drive it if you're not leader! What can i do for that? Is there a problem with the respawn? Thx ! I can confirm this. Script needs to make respawned vehicle "unlocked". Share this post Link to post Share on other sites
Osmo88 10 Posted May 5, 2013 Hi! My issue is that when I test me vehicle respawn in editor I got this: '...tDir _dir; if (_haveinit) then {_unit |#|SetVehicleInit format ["x1;", _unitinit]...' "error Missing ; File: "the root where the vehicle.sqf is", line 116 Share this post Link to post Share on other sites
[evo] dan 79 Posted May 5, 2013 (edited) Hi! My issue is that when I test me vehicle respawn in editor I got this: '...tDir _dir; if (_haveinit) then {_unit |#|SetVehicleInit format ["x1;", _unitinit]...' "error Missing ; File: "the root where the vehicle.sqf is", line 116 setVehicleInit command no longer exists so has broken your version of the script Have a try of this until tophe fixes it himself, its a lot more basic, but covers you basic respawn with a timer: _vehicle = _this select 0; //get vehicle's details _respawntime = _this select 1; //get the init set respawn time _facingofvehicle = getDir _vehicle; //get original facing _positionofvehicle = getPosATL _vehicle; //get original position _vehicletype = typeOf _vehicle; //get the vehicle type _n = 1; if(isServer) then{ while{_n == 1} do{ if((!alive _vehicle) || (!canMove _vehicle)) then { //true if vehicle is not alive or it cannot move sleep 240; deleteVehicle _vehicle; //clear up old vehicle sleep _respawntime; // respawn time between deletion and then respawn _vehicle = _vehicletype createVehicle _positionofvehicle; // create a new vehicle of same type at starting position _vehicle setPosATL _positionofvehicle; //set correct position _vehicle setDir _facingofvehicle; //set correct facing of the vehicle [[[_vehicle,_respawntime],"vehicle_respawn.sqf"],"BIS_fnc_execVM",false,false] spawn BIS_fnc_MP; //replacement for the old setVehicleInit, this does the same and causes the new vehicle to have the respawn script when created _n = 0; // break out condition }; sleep 60; // sleep for a bit in order to reduce processing calls }; }; To use: -Make sure you copy this code into a script called vehicle_respawn.sqf -To execute it, put in the init of the vehicle you want to respawn 0 = [this,5] execVM "vehicle_respawn.sqf" , changing the 5 to the respawn time you want -This should work in both singleplayer and multiplayer. I hope I am allowed to put this in this thread, will create its own and delete this from here if its not. Edited May 5, 2013 by [EVO] Dan Share this post Link to post Share on other sites
brad7 4 Posted May 5, 2013 Dan;2388923']setVehicleInit command no longer exists so has broken your version of the scriptHave a try of this until tophe fixes it himself' date=' its a lot more basic, but covers you basic respawn with a timer: _vehicle = _this select 0; //get vehicle's details _respawntime = _this select 1; //get the init set respawn time _facingofvehicle = getDir _vehicle; //get original facing _positionofvehicle = getPosATL _vehicle; //get original position _vehicletype = typeOf _vehicle; //get the vehicle type _n = 1; if(isServer) then{ while{_n == 1} do{ if((!alive _vehicle) || (!canMove _vehicle)) then { //true if vehicle is not alive or it cannot move sleep 240; deleteVehicle _vehicle; //clear up old vehicle sleep _respawntime; // respawn time between deletion and then respawn _vehicle = _vehicletype createVehicle _positionofvehicle; // create a new vehicle of same type at starting position _vehicle setPosATL _positionofvehicle; //set correct position _vehicle setDir _facingofvehicle; //set correct facing of the vehicle [[[_vehicle,_respawntime],"vehicle_respawn.sqf"],"BIS_fnc_execVM",false,false] spawn BIS_fnc_MP; //replacement for the old setVehicleInit, this does the same and causes the new vehicle to have the respawn script when created _n = 0; // break out condition }; sleep 60; // sleep for a bit in order to reduce processing calls }; }; To use: -Make sure you copy this code into a script called vehicle_respawn.sqf -To execute it, put in the init of the vehicle you want to respawn 0 = [this,5'] execVM "vehicle_respawn.sqf" , changing the 5 to the respawn time you want -This should work in both singleplayer and multiplayer. I hope I am allowed to put this in this thread, will create its own and delete this from here if its not. My isnt working either but i get no error messages, ive tried your script and it dosent work either? Share this post Link to post Share on other sites
[evo] dan 79 Posted May 5, 2013 where are you putting this code? could you zip your mission and send it to me (provided its not using mods)? Share this post Link to post Share on other sites
brad7 4 Posted May 5, 2013 i create a respawn_vehicle.SQF and copy the text into that then i put 0 = [this,5] execVM "vehicle_respawn.sqf" in the init of the vehicles...? Share this post Link to post Share on other sites
[evo] dan 79 Posted May 5, 2013 i create a respawn_vehicle.SQF and copy the text into that then i put 0 = [this,5] execVM "vehicle_respawn.sqf" in the init of the vehicles...? your using my code incorrectly in your case. rename the file you called 'respawn_vehicle.sqf' to vehicle_respawn.sqf as your problem seems to be that it wont even execute it because the file doesn't exist because you named it wrong. Share this post Link to post Share on other sites
brad7 4 Posted May 5, 2013 ohh sorry i got mixed up i created a vehicle_respawn.SQF file Share this post Link to post Share on other sites
[evo] dan 79 Posted May 5, 2013 ohh sorry i got mixed up i created a vehicle_respawn.SQF file did you get it to work then? Share this post Link to post Share on other sites
brad7 4 Posted May 5, 2013 no i mean initially i put that i just wrote it wrong way round when writing the post Share this post Link to post Share on other sites
[evo] dan 79 Posted May 5, 2013 could you zip the mission then since I cannot see why it wouldn't work for you because its working for me right now Share this post Link to post Share on other sites
brad7 4 Posted May 5, 2013 Its got loads of different mods in it, could you post/send some step screenshots to see where im going wrong? Share this post Link to post Share on other sites
[evo] dan 79 Posted May 5, 2013 Try this (its works for me), and see if you can figure out what you have done differently: https://dl.dropboxusercontent.com/u/28062918/vehicle_respawn_test.Stratis.rar Share this post Link to post Share on other sites
brad7 4 Posted May 5, 2013 Yeh cheers mate it must have been the .sqf file that was wrong thanks for that.. Share this post Link to post Share on other sites