Jump to content
Sign in to follow this  
Stuntman

Vehicle Respawn - multiple vehicles of one type

Recommended Posts

Hello guys.

I'm using a vehicle respawn script in a MP mission I'm making. Its ported from OFP. Its not the built in ArmA script, because in my script every individual vehicle will respawn at its starting position.

My problem is, when there are more than me on a dedicated server, the vehicles respawn more than once.

If there are 5 people on, 5 bmp's respawn for example.

What can I do to prevent this to happen?

I'm not on my mission pc right now, so if you need the script receipt, please tell me and I'll get that posted.

Thanks in advance! smile_o.gif

Share this post


Link to post
Share on other sites
You respawn script must be run only in server, not in each client.

Yup, there should be an ?!isserver:exit check at the start of the script.

Share this post


Link to post
Share on other sites

Sadly it did not work. sad_o.gif

The vehicles still respawn more than once.

I hope you can help me here, I will write how its set up-

This is how I have set the script to work:

in the init file of every empty vehicle, I write

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[this, xxx] exec "vehciles.sqs"

xxx is the amount of time in seconds before they respawn.

"vehicles.sqs" is the respawn script file located in the mission folder.

Some of the vehicles respawn at 10, some at 300, some at 180 etc.

This is how the script looks like:

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

?!isserver:exit

~2

_vcl = _this select 0

_vcltype = typeof _vcl

_vcldir = getdir _vcl

_vclpos = getpos _vcl

_delay = _this select 1

#alive

?! alive _vcl:goto "notalive"

~1

goto "alive"

#notalive

~_delay

deletevehicle _vcl

~1

_vcl = _vcltype createvehicle _vclpos

_vcl setdir _vcldir

goto "alive"

Is this information helpful enough? Is the script maybe wrong or something wrongly placed?

Hope you guys can help me here!

smile_o.gif

Share this post


Link to post
Share on other sites

Can't say exactly whats wrong there but i've wrote an own respawn script.

It is in sqf and should be a little more CPU friendly.

vehicle_respawn.sqf

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

if (! isServer) exitwith {};

sleep 2;

_vehicle = _this select 0;

_delay = _this select 1;

_numbers = _this select 2;

_counter = 0;

_veh_type = typeof _vehicle;

_veh_pos = getpos _vehicle;

_veh_dir = getdir _vehicle;

while {_counter != _numbers} do {

       while {alive _vehicle} do {sleep 1};

       sleep ((_delay/5)*4);

       deletevehicle _vehicle;

       sleep (_delay / 5);

       _vehicle = _veh_type createvehicle _veh_pos;

       _vehicle setdir _veh_dir;

       _counter = _counter + 1;

};

Call this script from the initline as you did before:

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

nul = [this, 50, -1] execVM "vehicle_respawn.sqf"

I've added a third parameter to make limited respawns. If you set -1 it is unlimited, else just insert the number of times the vehicle should respawn (i.e. 5 will let the vehicle 5 times).

Hope this helps and you get your problem solved.

Myke out

Share this post


Link to post
Share on other sites

Thanks a lot pal!

I will give you a message if it does or does not work. smile_o.gif

Share this post


Link to post
Share on other sites

The script works, but after intense respawn tests, its starting to bug out after 3 mins. confused_o.gif

I will try to say it as clear as possible: they respawn in order again and again. But after 3 minutes of respawning right after each other, they suddenly start to respawn at a random time.

Its respawning multiple vehciles at the same time....but one at the correct time and the rest at a random time.

This continues to happen; if we blow one tank up, one will respawn at correct time....and one will do it in random time afterwards.

In the end we got like 4 tanks at one respawn point, and if we destroy on of those 4 tanks, they stack up etc.

Is this an ArmA limitation?

Share this post


Link to post
Share on other sites

Odd things happen to you, mate.

Let's see if it is really only running on the server. Please edit the script like this:

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

if (! isServer) exitwith {};

hint "You shouldn't see this";

sleep 2;

It's one line added. After changing this, do some more tests. Unless someone is hosting (means, you don't play on dedicated) then no one should see the message. If someone hosts, only this player should see the message.

And, if possible, please watch if

- a player was/is in the killed vehicle

- if several players where in the vehicle, does the too many respawned vehicles correspond with players that where in the vehicle.

Probably not easy to track but i have an idea what it could be. So those info would help to verify if i'm right or wrong.

Share this post


Link to post
Share on other sites

Going to test it out.

Btw, I forgot to tell you that I have both the custom script for empty vehicles (target practise) and the built in arma vehicle respawn script for some other tanks spread around.

in the description.ext I have "respawnVehicleDelay = 180;"

So I wonder if that built in script for some odd reason conflicts with the custom script?

Share this post


Link to post
Share on other sites

Didnt get any such hint message on a dedicated, but respawn still bugged. banghead.gif

You have any idea? Is it conflicting with arma respawn script?

Annoyingly even with very little respawn, that I only killed the tragets 2 times or so, they still after some time respawn multiple times at random times.

confused_o.gif

Share this post


Link to post
Share on other sites

It would help to track down the problems if you would test the script without any other respawn stuff.

If problems occure, it's always a good idea to watch if all components work for themselves and then adding one by one to the mission. As soon it start bugging, you may guess what does interfere with eachother.

Share this post


Link to post
Share on other sites

just thought did you place a game logic trigger?

that solved my multiple respawn issue

Share this post


Link to post
Share on other sites
just  thought did you place a game logic trigger?

that solved my multiple respawn issue

yep, I'm not sure if it is still needed, but I got in the habit long ago of putting a game logic named server somewhere on the map, seemed to always eliminate troubles and even if not needed now, it doesn't cause any troubles.

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  

×