Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Based on [EVO] Dan's vehicle respawn script modified by Steam-User immerfestedruv
- In the Unit Init Field insert <0 = [this,5,"blackfish_1","Driver",helipad_2,15] execVM "unit_respawn.sqf";> for example.
- Will run only on the server, as it only needs to run in one place,
- but obviously can be used in both singleplayer and multiplayer */
- _unit = _this select 0; // First Argument, get Unit's details
- _delay = _this select 1; // Second Argument,get the init set respawn time
- _vehCall = _this select 2; // Third Argument, the Variable-Name of the unit's vehicle(Call-Sign)
- _vehSeat = _this select 3; // Forth Argument, on which Seat shall the unit sit
- _parkPlace = _this select 4; // Fifth Argument, the place where the vehicle parks
- _parkRad = _this select 5; // Sixth Argument, possible park Radius from the center of the vehicle park
- _parkPos = getPos _parkPlace; // Fith Argument, get the Position of the supposed vehicle park
- _dirUnit = getDir _unit; // get original facing
- _posUnit = getPosATL _unit; // get original position
- _unitType = typeOf _unit; // get the unit type
- _unitgroup = group _unit; // get group of the original unit
- _unitName = vehicleVarName _unit; // get the Variable-Name of the unit
- _unitRank = rank _unit; // get the units orignal rank
- _unitSkill = skill _unit; // get the original skill of the unit
- _vehicle = nil; // the units vehicle will be determined in the code below
- _n = 1;
- if(isServer) then{
- while{_n == 1} do{
- sleep 20; // sleep for a bit in order to reduce processing calls
- if((!alive _unit) || (!canMove _unit)) then { //true if unit is not alive or it cannot move
- deleteVehicle _unit; // clear up old units
- sleep _delay; // respawn time between deletion and respawn
- // create a new unit of same type at starting position
- _unitType createUnit [_posUnit, _unitgroup,"_unit = this", _unitSkill, _unitRank];
- _unit setPosATL _posUnit; // set correct position
- _unit setVehicleVarName _unitName;
- _unit setDir _dirUnit; // set correct facing of the unit
- /* Next Code-Line will be executed for the new Object by your CPU, but time of execution unkown.
- This behaves similar to the code in the init-field of your object. */
- [[[_unit,_delay,_vehCall,_vehSeat,_parkPlace,_parkRad],"unit_respawn.sqf"],"BIS_fnc_execVM",false,false] spawn BIS_fnc_MP;
- _n = 0; // break out condition
- } else {
- /*The Vehicle shall be manned if its alive, therefore we have to search for the vehicle. We have
- the Call-Sign and the place of the vehicle park where it should be.*/
- _nearObjs = nearestObjects [_parkPos,[],_parkRad];
- //hint format ["Liste aller Objekte %1",_nearObjs];
- for "_i" from 0 to (count _nearObjs - 1) do {
- if ((vehicleVarName (_nearObjs select _i)) == _vehCall) then {
- if (!isNull (_nearObjs select _i)) then {
- if (alive (_nearObjs select _i)) then {
- _vehicle = _nearObjs select _i;
- switch (_vehSeat) do {
- case "Driver": {_unit moveInDriver _vehicle};
- case "Gunner": {_unit moveInGunner _vehicle};
- case "Turret": {_unit moveInTurret _vehicle};
- case "Commander": {_unit moveInCommander _vehicle};
- default {_unit moveInCargo _vehicle};
- };
- };
- };
- };
- };
- };
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement