Jump to content
Sign in to follow this  
mattxr

Vehicle Respawn Template

Recommended Posts

1)  Place a Game logic in the mission editor.  Name it Server.

2)  Place a vehicle in the mission editor.  

3) In the init field of the vehicle put:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">s = this execVM "vrs.sqf"

4) Copy the code from my earlier post into a file named vrs.sqf and put it in your mission directory.

Now it should work.

Share this post


Link to post
Share on other sites

I made a small change to the script.  The While{}...do{} loop has a hard-coded 10,000 loop limit and in longer games, there's always the possibility it could hit that limit and exit.  I tweaked the script to use the for...do loop instead which AFAIK is infinite.  

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">for [{}, {_run}, {_run}] do

is the only change I made.  I edited my post with the change in case you want to update the script.

Share this post


Link to post
Share on other sites

Does anyone else get an error while trying to use Kar's script?

_dir = |#|Getdir _vcl;

Error getdir: Type Array, expected Object (line 12 vrs.sqf)

When you start the game.

I'm hosting a game using the game client while testing this, is this ok, or do I need to PBO it and put it on a dedicated for it to work?

Thanks

Share this post


Link to post
Share on other sites

Make sure in the init field you put:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">s = this execVM "vrs.sqf"

It sounds like for some reason it's pulling an empty array into the script.  You might have:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">s = [] execVM "vrs.sqf"

Make sure the exec statement is correct and let me know.

This script can be used on dedicated or host servers--it'll work either way.

EDIT: I'd listed the exec statement incorrectly in my previous post. Corrected now.

Share this post


Link to post
Share on other sites

yay.gif

Thanks KaRRiLLioN! Works great and the vehicles respawn exactly where they are supposed to unlike in other scripts where they move slightly every time they spawn.

Loved all your missions for OFP, looking forward to some ArmA ones! pistols.gif

Share this post


Link to post
Share on other sites

@ KaRRiLLioN

I've been using your script in combination with some others I have written that allow non-playable AI units to respawn and get in a respawning HMMWV50 before moving through waypoints to a destination and I have run into a fairly annoying and major bug where by if the gunner is killed enroute to the waypoint his corpse won’t disappear and this prevents the vehicle from respawning.  I have tried scripting it so that the gunners corpse is deleted the moment he dies but for some reason his corpse just won’t disappear.  

Have you ever experienced the same problem with your script?

I think it may occur in my case because even though the gunner is dead his body may be being counted as crew by your script.

I'm not sure if the syntax of this would work (cause I'm at work and can't try it) but do you think some sort of statement like this added to your script would fix this problem?  

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">while {!alive gunner _vcl && canMove _vcl && count Crew _vcl < 2 } do  

Share this post


Link to post
Share on other sites

I've never had that issue AFAIK. Count Crew Vehicle only counts living crew, I believe. In CTF's and such we've had many instances where players and AI were killed in vehicles and they respawned properly.

I suppose you could try to set up a debug statement, i.e.:

player groupchat format ["%1",count crew _vcl]

or something just to see if dead crew are counted as crew. If so, it's a change from OFP and something like your statement will probably work.

Share this post


Link to post
Share on other sites

Let me start out by saying that this is not a problem if the gunner is a playable unit but if he is a non-playable AI unit and he's dead if I change the code to read this the vehicle will now respawn.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

// *****************************************************

//** Operation Flashpoint Script File

//*****************************************************

//BEGIN vrs.sqf

//By KaRRiLLioN

//IMPORTANT: ADD A GAMELOGIC NAMED Server

//to the mission to prevent multispawn

private ["_vcl","_respawndelay","_dir","_pos","_type","_run","_crewWait","_wait","_delay"];

if (!local Server) exitWith {};

_vcl = _this;

_respawndelay = 20;

_dir = Getdir _vcl;

_pos = Getpos _vcl;

_crewWait = 10;

_wait = 0;

_type = typeOf _vcl;

_run = TRUE;

sleep 1;

for [{}, {_run}, {_run}] do

{

   while {canMove _vcl && count crew _vcl < 2} do

   {

        _wait = Time + _crewWait;

        sleep 1;

   };

   while {Count crew _vcl > 1 && Alive _vcl} do

   {

        _wait = Time + _crewWait;

        sleep 1;

   };

   while {canMove _vcl && count Crew _vcl < 2 && Time < _wait} do

   {

        sleep 1;

   };

   _delay = Time + _respawnDelay;

   while {!canMove _vcl && count Crew _vcl < 2 && Time < _delay} do

   {

        sleep 1;

   };

   if (count Crew _vcl < 2)then

   {

deleteVehicle _vcl;

        _vcl = _type createVehicle _pos;

_vcl setdir _dir;

        sleep 1;

        _vcl setvelocity [0,0,0];

        _vcl setpos _pos;

        sleep 1;

        _vcl setvelocity [0,0,0];

  hint "respawn vehicle";

   };

};

So it seems that there is a difference in the way the game treats dead playable and non playable units when they are in the gunner position in vehicles.  I think what may be happening is that if the unit is playable when you shoot it its body falls out of the gunner position onto the ground and the script can continue but in the case of nonplayable AI its corpse doesn't disappear and as its still draped in the gunner position for some reason is being counted as a crew member.

This also explains why the script locks up the game if an non playable AI filled vehicle is destroyed while all are on board as the script thinks all the crew are alive but the vehicle is dead.  Now how to deal with this is the next question.

Share this post


Link to post
Share on other sites

After playing around with the vrs script for some time I've come up with this.  As far as I can tell, on a local server anyway, if you modify your script like this it will work for both playable and non-playable AI units. The vehicle will now respawn if a non-playable AI corpse is present in the gunner's position and destroying the vehicle with a rocket while crewed by AI units no longer locks up the game.

Note this code was written initially for use with respawning non playable AI units, however as far as I can tell (with limited play testing on a local server) it will also work with playable units and therefore may be used as an alternative to KaRRiLLioN's original vrs code.

Please let me know if you run into any probs.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// *****************************************************

//** Operation Flashpoint Script File

//*****************************************************

//BEGIN vrs_AI.sqf

//Original script by KaRRiLLioN modified by norrin for AI units 4th Feb 2007

//IMPORTANT: ADD A GAMELOGIC NAMED Server

//to the mission to prevent multispawn

private ["_vcl","_respawndelay","_dir","_pos","_type","_unit","_run","_wait"];

if (!local Server) exitWith {};

_vcl = _this;

_respawndelay = 20;

_dir = Getdir _vcl;

_pos = Getpos _vcl;

_type = typeOf _vcl;

_unit = driver _vcl;

_run = TRUE;

sleep 5;

for [{}, {_run}, {_run}] do

{

while {_vcl distance _pos < 5 && canMove _vcl} do

  {

 sleep 1;

  };

while {canMove _vcl && count crew _vcl > 0 && ({damage _x}forEach crew _vcl)!= 1} do  

  {

_wait = Time + _respawndelay;

sleep 1;

  };

while {count crew _vcl < 1 && Time < _wait} do

  {

sleep 1;

  };

while {{damage _x} forEach crew _vcl >= 1 && Time < _wait} do

  {

sleep 1;

  };

if (count crew _vcl < 1) then

  {

  deleteVehicle _vcl;

        _vcl = _type createVehicle _pos;

  _vcl setdir _dir;

        sleep 1;

        _vcl setvelocity [0,0,0];

        _vcl setpos _pos;

        sleep 1;

        _vcl setvelocity [0,0,0];

  hint "respawn vehicle";

  sleep 2;

   };

if ({damage _x} forEach crew _vcl >= 1)then

  {

  deleteVehicle _vcl;

        _vcl = _type createVehicle _pos;

  _vcl setdir _dir;

        sleep 1;

        _vcl setvelocity [0,0,0];

        _vcl setpos _pos;

       sleep 1;

        _vcl setvelocity [0,0,0];

  hint "respawn vehicle";

  sleep 1;

   };

sleep 2;

};

EDIT: Updated script and text.

Share this post


Link to post
Share on other sites

After a request from 169th_Ice I've revised my vrs_AI.sqf script so that you can specify different times for the length of respawn wait for when a vehicle is left empty or if a vehicle is destroyed much like KaRRiLLioN's original version of this script.  You can d/l a copy of my revised vrs_AI.sqf script here  

Here's the code of the revised script for anyone interested

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

// *****************************************************

//** Operation Flashpoint Script File

//*****************************************************

//BEGIN vrs_AI.sqf

//Original script by KaRRiLLioN modified by norrin for AI units 7th Feb 2007

//IMPORTANT: ADD A GAMELOGIC NAMED Server

//to the mission to prevent multispawn

private ["_vcl","_respawndelay","_vclemptydelay","_dir","_pos","_type","_unit","_run","_wait","_delay"];

if (!local Server) exitWith {};

_vcl = _this;

//specify the respawn wait times for empty vehicles and destroyed vehicles in the following 2 lines

_vclemptydelay = 60;

_respawndelay = 20;

_dir = Getdir _vcl;

_pos = Getpos _vcl;

_type = typeOf _vcl;

_unit = driver _vcl;

_run = TRUE;

sleep 5;

for [{}, {_run}, {_run}] do

{

while {_vcl distance _pos < 5 && canMove _vcl} do

  {

 sleep 1;

  };

while {canMove _vcl && count crew _vcl > 0 && ({damage _x}forEach crew _vcl)!= 1} do  

  {

_wait = Time + _vclemptydelay;

sleep 1;

  };

while {canMove _vcl && count crew _vcl < 1 && Time < _wait} do

  {

sleep 1;

  };

while {canMove _vcl && {damage _x} forEach crew _vcl >= 1 && Time < _wait} do

  {

sleep 1;

  };

_delay = Time + _respawndelay;

while {!canMove _vcl && Time < _delay} do

  {

sleep 1;

  };

if (count crew _vcl < 1) then

  {

  deleteVehicle _vcl;

        _vcl = _type createVehicle _pos;

  _vcl setdir _dir;

        sleep 1;

        _vcl setvelocity [0,0,0];

        _vcl setpos _pos;

        sleep 1;

        _vcl setvelocity [0,0,0];

  hint "respawn vehicle";

  sleep 2;

   };

if ({damage _x} forEach crew _vcl >= 1)then

  {

  deleteVehicle _vcl;

        _vcl = _type createVehicle _pos;

  _vcl setdir _dir;

        sleep 1;

        _vcl setvelocity [0,0,0];

        _vcl setpos _pos;

       sleep 1;

        _vcl setvelocity [0,0,0];

  hint "respawn vehicle";

  sleep 1;

   };

sleep 2;

};

Share this post


Link to post
Share on other sites

Hi,

I think I've got it but I just have one small question... biggrin_o.gif

I've exported my mission but I cant find it in the mulitplayer/host section.

I copied it to my mpmissions folder in my docs and the C:\ but it still doesnt show.

I renamed it earlier which may have caused a problem. huh.gif

Should I change it back?

EDIT*

Nevamind, I have found that it is just in the mydocs/username/mission folder. (I had multiple versions saved all over)

Altho I found my map is not called what it is supposed to be called. Which is the best way to save and change name?

Rename it in the folder first and then in the editor?

Share this post


Link to post
Share on other sites

I have a question about these respawn scripts.

I am using a veh respawn script but then I'm also using triggers that prevent non-pilots from piloting aircraft. The problem is that my triggers require me to name each separate aircraft. This all works fine until the first aircraft is destroyed-- when it respawns it seems to have lost its 'name' and thus anyone can fly it now, not just pilots.

How have some of you worked around this? Maybe I need a script for the pilot restrictions instead of triggers? Thanks.

Share this post


Link to post
Share on other sites

Here some updated code for the VRS_AI.sqf.  The changes will allow you to specify the vehicle empty respawn and vehicle destroyed respawn delays for each vehicle you place on the map.  

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

//BEGIN vrs_AI.sqf

//Original script by KaRRiLLioN modified by norrin for AI units March 2007

//IMPORTANT: ADD A GAMELOGIC NAMED Server

//to the mission to prevent multispawn

//to run this script place the following code in the init line of the vehicle:

// v = [this, x, y] execVM "vrs_AI.sqf"

//where x and y are the times you wish to set for the vehicle empty respawn delay and vehicle destroyed respawn delay

private ["_vcl","_respawndelay","_vclemptydelay","_dir","_pos","_type","_unit","_run","_wait","_delay"];

if (!local Server) exitWith {};

_vcl = _this select 0;

_vclemptydelay = _this select 1;

_respawndelay = _this select 2;

_dir = Getdir _vcl;

_pos = Getpos _vcl;

_type = typeOf _vcl;

_unit = driver _vcl;

_run = TRUE;

sleep 5;

for [{}, {_run}, {_run}] do

{

while {_vcl distance _pos < 5 && canMove _vcl} do

  {

 sleep 1;

  };

while {canMove _vcl && count crew _vcl > 0 && ({damage _x}forEach crew _vcl)!= 1} do  

  {

_wait = Time + _vclemptydelay;

sleep 1;

  };

while {canMove _vcl && count crew _vcl < 1 && Time < _wait} do

  {

sleep 1;

  };

while {canMove _vcl && {damage _x} forEach crew _vcl >= 1 && Time < _wait} do

  {

sleep 1;

  };

_delay = Time + _respawndelay;

while {!canMove _vcl && Time < _delay} do

  {

sleep 1;

  };

if (count crew _vcl < 1) then

  {

  deleteVehicle _vcl;

        _vcl = _type createVehicle _pos;

  _vcl setdir _dir;

        sleep 1;

        _vcl setvelocity [0,0,0];

        _vcl setpos _pos;

        sleep 1;

        _vcl setvelocity [0,0,0];

  sleep 2;

   };

if ({damage _x} forEach crew _vcl >= 1)then

  {

  deleteVehicle _vcl;

        _vcl = _type createVehicle _pos;

  _vcl setdir _dir;

        sleep 1;

        _vcl setvelocity [0,0,0];

        _vcl setpos _pos;

       sleep 1;

        _vcl setvelocity [0,0,0];

  sleep 1;

   };

sleep 2;

};

@berowe

You could try sending the name of the unit directly to the script.  Using the latest version of the script, if the unit’s name was dog and you wanted both respawn delays set at 10 seconds then in the init line you’d put this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">v = [this, 10, 10, “dogâ€] execVM "vrs_AI.sqf"

Then in the script you’d have to add

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _name_vcl  = _this select 3; at the start of the script and

when the vehicle is created toward the end of the script you need to add this line directly after the createVehicle line (this happens twice so you need to add this new line after each instance of createVehicle)

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _vcl setVehicleVarName _name_vcl; .

If you run into any probs send me your file to norrins_nook@iprimus.com.au and I’ll fix it up for you.

@MeNez

A couple of ways you can do this but you’re best to rename it in the MPmissions directory, the new folder will appear next time you log into your local server.  If you change the mission name in the editor it creates a new folder but none of the scripts and additional files are sent across to the new folder.

Just to protect my older working versions I find it best to copy the mission folder and then paste it back into the MPmissions directory and rename it and then restart my local server.

Share this post


Link to post
Share on other sites

Thanks Norrin. Will doo!

Just one thing. I copied your script exactly and added the init lines to a couple vehicles I wanted to test the respawn on.

When I run the map in MP I get an error on the top left corner, similar to the one you listed earlier.

ydelay = 20; (couldnt read beginning, Fraps FPS in way)

_respawndelay = 10;

_dir = l#lGetdir _vcl;

_pos = Getpos _vcl;

_type = ...'

Error getdir: Type Array, expected object

File MPmissions\__cur_mp.Sara\vrs.sqf, line 18

Any idea what it means?? confused_o.gif

Share this post


Link to post
Share on other sites

Matt & Guys,

Do you know of a version that gets around a problem with respawning AH1Z's and other Aircraft from being able to reload FFARs and HellFire's?

I'm using this script, and it's awesome for everything but that bug above...

Not sure who wrote it, but it's called vehirespawn.sql

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

; Call in initline with (120 for 120 seconds, 2 minutes) :

;

; [this, 120] exec "vehirespawn.sqs"

;

; Note - This script needs a "GameLogic" trigger named "SERVER" or else spawning will be nuts

;

?! (local server): exit

~3

_vehicle = _this select 0

_delay = _this select 1

_empty = true

_disabled = false

_moved = false

_startpos = getpos _vehicle

_startdir = getdir _vehicle

_type = typeof _vehicle

#waiting

~2

_newpos = getpos _vehicle

?! (_newpos select 0 in _startpos) or not (_newpos select 1 in _startpos): _moved = true

?! (isnull driver _vehicle) or not (isnull gunner _vehicle) or not (isnull commander _vehicle): _empty = false

? (isnull driver _vehicle) and (isnull gunner _vehicle) and (isnull commander _vehicle): _empty = true

?! (canmove _vehicle) or (canfire _vehicle): _disabled = true

? (canmove _vehicle) and (canfire _vehicle): _disabled = false

? (_disabled) and (_empty): goto "spawn"

? (_moved) and (_empty): goto "spawn"

goto "waiting"

#spawn

~_delay

?! (isnull driver _vehicle) or not (isnull gunner _vehicle) or not(isnull commander _vehicle): _empty = false

?! (_empty): goto "waiting"

deletevehicle _vehicle

~0.5

_newveh = _type createvehicle _startpos

_newveh setpos _startpos

_newveh setdir _startdir

[_newveh, _delay] exec "vehirespawn.sqs"

exit

Share this post


Link to post
Share on other sites

Hey props to you satexas69!!!

I copied your script and its working shweet!

Although, I'm now in the same boat as you with regards to the re-arm of choppers.

I remember reading that it is a glitch but if you keep one hellfire left then it will reload all. (Just have to be mindfull not use ALL your ammo until a fix comes out)

Later* goodnight.gif

Share this post


Link to post
Share on other sites

@ MeNeZ sounds like you may have mixed the init line execution code and the scripts. With all the changes to this script its not surprising.

I'll make some download links for the various versions of the vrs_AI script with some explanatory notes on how to use each version later today.

@satexas69, I think I've got a fix for your reload problem as I've done something similar for Wedge for the harriers over at OPFEC which you can read about here: http://www.ofpec.com/index.p....28849.0

I just need to add some code to the vrs script which I'll do a bit later today.

Share this post


Link to post
Share on other sites

Karrillion & Matt -

We have a problem! smile_o.gif

My script (posted 2-3 posts above) doesn't give the vehicle the same "name" as it had in the editor before it respawned....

... I need the respawn process to somehow include putting the unit's name BACK on the vehicle - is this possible?huh.gif?

Why? Because I have a "pilot can only pilot choppers" situation - but if I put a few rockets into a chopper and respawn it, it loses it's name and thus allows ANYONE to pilot it... bad bad bad.

Help? smile_o.gif

Share this post


Link to post
Share on other sites

Came across this post while I was looking for something else and I don't know if you still want this but here's the most recent version of my vrs_AI script that sets the name of the respawning vehicle to the name given in the editor.  It also allows you to specify the empty and destroyed respawn times for individual vehicles.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> //BEGIN vrs_AI_general.sqf

//Script by norrin March 2007

//Based upon KaRRiLLioN's original vrs.sqf script modified for use with playable and non-playable AI units

//Contact me at norrins_nook@iprimus.com.au

//IMPORTANT: ADD A GAMELOGIC NAMED Server

//to the mission to prevent multispawn

//to run this script place the following code in the init line of the vehicle:

// v = [this, "vehicle name", x, y] execVM "vrs_AI_general.sqf"

//where x and y are the times you wish to set for the vehicle empty respawn delay and vehicle destroyed respawn delay

//Note: the vehicle name must be in quotation marks eg. if vehicle name Hmm1 it must appear in the init line as "Hmm1"

private ["_vcl","_respawndelay","_vclemptydelay","_dir","_pos","_type","_unit","_run","_wait","_delay"];

if (!local Server) exitWith {};

_vcl = _this select 0;

_name_vcl = _this select 1;

_vclemptydelay = _this select 2;

_respawndelay = _this select 3;

_dir = Getdir _vcl;

_pos = Getpos _vcl;

_type = typeOf _vcl;

_run = TRUE;

sleep 5;

for [{}, {_run}, {_run}] do

{

   while {_vcl distance _pos < 5 && canMove _vcl} do

     {

        sleep 1;

     };

   while {canMove _vcl && count crew _vcl > 0 && ({damage _x}forEach crew _vcl)!= 1} do  

     {

       _wait = Time + _vclemptydelay;

       sleep 1;

   };

   while {canMove _vcl && count crew _vcl < 1 && Time < _wait} do

   {

       sleep 1;

   };

   while {canMove _vcl && {damage _x} forEach crew _vcl >= 1 && Time < _wait} do

   {

       sleep 1;

   };

   _delay = Time + _respawndelay;

   while {!canMove _vcl && Time < _delay} do

     {

       sleep 1;

     };

   if (count crew _vcl < 1) then

     {

         deleteVehicle _vcl;

           _vcl = _type createVehicle _pos;

         _vcl setVehicleVarName _name_vcl;

           _vcl setdir _dir;

           sleep 1;

           _vcl setvelocity [0,0,0];

           _vcl setpos _pos;

           sleep 1;

           _vcl setvelocity [0,0,0];

         sleep 2;

      };

   if ({damage _x} forEach crew _vcl >= 1)then

     {

         deleteVehicle _vcl;

           _vcl = _type createVehicle _pos;

          _vcl setVehicleVarName _name_vcl;

           _vcl setdir _dir;

           sleep 1;

           _vcl setvelocity [0,0,0];

           _vcl setpos _pos;

           sleep 1;

           _vcl setvelocity [0,0,0];

         sleep 1;

      };

   sleep 2;

};

You can down load the script from here: http://home.iprimus.com.au/simonns....tro.rar

In the init line of the unit you'll need to put something like this

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> v = [this, "vehicle name", x, y] execVM "vrs_AI_general.sqf"

where the vehicle name is the name given in the editor in quotation marks (eg "Hummer1", "Chopper2" etc) and x is the respawn time for the vehicle when empty and y is the respawn time after it has been destroyed.

Don't forget to add a gamelogic called server to stop multiple vehicle respawning.

Share this post


Link to post
Share on other sites

Got a request for this and I thought it may be of use to other mission makers.  Here's a version of the vrs script that only respawns vehicles if they are destroyed or cannot move.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">/*

  VEHICLE RESPAWN SCRIPT SQF

  Respawns vehicles when they are destroyed or cannot move

  © May 2007 - norrin (norrins_nook@iprimus.com.au), based upon KaRRiLLioN's original vrs.sqf script.

  Version:  1.0                      

******************************************************************************************

*********************************

IMPORTANT: ADD A GAMELOGIC NAMED Server to the mission to prevent multispawn

To run this script place the following code in the init line of the vehicle:

v = [this, "vehicle name", x] execVM "vrs_AI_general.sqf"

where x is the time you wish to set for the vehicle destroyed respawn delay

Note: the vehicle name must be in quotation marks eg. if vehicle name's Hmm1 it must appear in the init line as "Hmm1"

******************************************************************************************

**********************************

Start vrs_AI_general.sqf

*/

private ["_vcl","_respawndelay","_dir","_pos","_type","_run","_delay"];

if (!local Server) exitWith {};

_vcl = _this select 0;

_name_vcl = _this select 1;

_respawndelay = _this select 2;

_dir = Getdir _vcl;

_pos = Getpos _vcl;

_type = typeOf _vcl;

_run = TRUE;

sleep 5;

for [{}, {_run}, {_run}] do

{

while {canMove _vcl} do  

  {

      sleep 1;

_delay = Time + _respawndelay;

  };

_delay = Time + _respawndelay;

    while {!canMove _vcl && Time < _delay} do

  {

      sleep 1;

  };

  if (!canMove _vcl && Time >= _delay) then

  {

        deleteVehicle _vcl;

          _vcl = _type createVehicle _pos;

        _vcl setVehicleVarName _name_vcl;

          _vcl setdir _dir;

          sleep 1;

          _vcl setvelocity [0,0,0];

          _vcl setpos _pos;

          sleep 1;

          _vcl setvelocity [0,0,0];

        sleep 2;

    };

};

Share this post


Link to post
Share on other sites

I found that the name of the vehicle must be set on each client separately for some weird reason, sure the respawn works as above for the Server, but when you use crew-check code then that must run local on each client.  So to get the client the name I had to fudge some publicVariables from the Server to the clients: one boolean that flags the new respawn, one 'hold' boolean that queues requests, and one object-variable set as the newly spawned object.

The client catches the flag-event in a trigger and locally sets the new object as named correctly.

Only problem is that sometimes this script locks up and stops respawning after some time but I can't for the life of me work out where or why it locks...

To see the vRD and vCC respawn and crewcheck scripts in action take a look inside the AirCav Onslaught map.

Probably a messy way to do it, if anyone has a better solution that does everything required then please give us a hint or three.

Onslaught Maps - using vRD and vCC SQS files with trigger catch on clients

Share this post


Link to post
Share on other sites

I am using Karillions script for Vehicle Respawn, the vrs.sqf one. And I can get the respawn to work only if there are AI's in the vehicle...I dont want them in the vehicle. Any thoughts on how i can fix this?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×