Jump to content
Sign in to follow this  
BelgarionNL

Dedi respawn script that keeps custom height and init vehicle code

Recommended Posts

I could not find this on the forums!

I used 2 addons the LCU (landing craft utility) which needs to respawn if destroyed with the same init vehicle code that I entered!

and the vehicles that are on the transport ship that also have custom height!

how do I do that?

Share this post


Link to post
Share on other sites

place last in init of your vehicles, 60 is amount of seconds after destroyed before respawned.

_null = [this,60] execVM "vehicleRespawn.sqf";
[code]

save this as vehicleRespawn.sqf
[code]
if (!isServer) exitWith {};

_veh = _this select 0;
if (getDammage _veh == 0) then {
sleep 2;  // just to make sure any custom settings have been applied.
_type = typeOf _veh;
_pos = getPos _veh;
_dir = getDir _veh;
_veh setVariable ["vehicleRespawnParams", [_type,_pos,_dir,(_this select 1)], true];
_idx = _veh addEventHandler ["killed", {_this execVM "vehicleRespawn.sqf"}]
} else {
_info = _veh getVariable "vehicleRespawnParams";
_tim = _info select 3;
sleep _tim;
_veh = createVehicle [(_info select 0), [0,0,1000], [], 0, "NONE"];
_veh setDir (_info select 2);
_veh setPos (_info select 1);
_null = [_veh,_tim] execVM "vehicleRespawn.sqf";
};

does not take into account custom tilting of vehicle nor cleans up the wrecks, for that you might want to just add it in the script after the creation sleep, or a garbage script or my DMZ Delete script.

Share this post


Link to post
Share on other sites

Demonized, the killed EH in your code snippet will not trigger if the locality of the vehicle has changed to a client.

Beside that, you don't have to send "vehicleRespawnParams" over the net, just store it on the server :)

Xeno

Share this post


Link to post
Share on other sites

off topic: hey Xeno love your work, very good stuff! can't wait what you cook up for Arma III

on topic: so xeno do you got a fix for demonized' script? or maybe an alternative that also cleans up the vehicle?

Share this post


Link to post
Share on other sites

the public true just was there from copy paste, ofc not needed.

i thought all vehicles reverted to server side once destroyed and no player inside...?

would use of addMPEventhandler and MPKilled work for that code snippet, with only the creation part on server side if then..?

Share this post


Link to post
Share on other sites

so i am trying out the simple vehicle respawn script untill I figure out your solution which is probably better but untill then:

this works:

veh = [this, 15, 120, 0, FALSE, FALSE, "this setPos [getPos this select 0, getPos this select 1, 12.5]"] execVM "scripts\vehicle_respawn.sqf"

but this needs to be added between the "": _xtype = [this,0] execvm "scripts\fold_aircraft\airpack.sqf"

how do i do that! everytime it says missing ]

veh = [this, 15, 120, 0, FALSE, FALSE, "this setPos [getPos this select 0, getPos this select 1, 12.5]; _xtype = [this,0] execvm "scripts\fold_aircraft\airpack.sqf""] execVM "scripts\vehicle_respawn.sqf"

Share this post


Link to post
Share on other sites

veh = [this, 15, 120, 0, FALSE, FALSE, "this setPos [getPos this select 0, getPos this select 1, 12.5]; _xtype = [this,0] execvm "scripts\fold_aircraft\airpack.sqf""] execVM "scripts\vehicle_respawn.sqf"

You missed the double quotation marks within the init code.

Share this post


Link to post
Share on other sites

so?

"this..."scripts...sqf " " i thought that would belance it out

veh = [this, 15, 120, 0, FALSE, FALSE, [color="DarkOrange"]"[/color][color="Red"]this setPos [getPos this select 0, getPos this select 1, 12.5][/color]; [color="Blue"]_xtype = [this,0] execvm "scripts\fold_aircraft\airpack.sqf"[/color][color="DarkOrange"]"[/color]] execVM "scripts\vehicle_respawn.sqf"

Edited by BelgarionNL

Share this post


Link to post
Share on other sites
so?

"this..."scripts...sqf " " i thought that would belance it out

something more like

"this...[color="Red"]""[/color]scripts...sqf[color="red"]""[/color] "

it's easily missed.

Share this post


Link to post
Share on other sites

i thought all vehicles reverted to server side once destroyed and no player inside...?

killed EH does only trigger/fire where the vehicle/object is local when it gets destroyed.

It has nothing to do with the server in this case, it's just a question of locality.

Beside that, locality of a vehicle does not switch back automatically to the server anymore once a client leaves the driver position (like it did some time ago).

would use of addMPEventhandler and MPKilled work for that code snippet, with only the creation part on server side if then..?

MPKilled does work well with vehicles. Just make sure that the MPKilled EH script has a isServer check as the MPKilled code will be executed on all instances, means server and clients.

Xeno

Share this post


Link to post
Share on other sites

sweet it works:

this setPos [getPos this select 0, getPos this select 1, 0]; _xtype = [this,0] execvm "scripts\fold_aircraft\airpack.sqf"; veh = [this, 15, 120, 0, FALSE, FALSE, "_xtype = [this,0] execvm ""scripts\fold_aircraft\airpack.sqf"""] execVM "scripts\vehicle_respawn.sqf"

---------- Post added at 06:56 PM ---------- Previous post was at 05:10 PM ----------

1 more thing I already ran this through squint and it gives 0 error and yet its not working:

veh = [this, 15, 120, 0, FALSE, FALSE, "this setvariable [""moored"", false, true]; this setvariable [""attachedobjs"", [], true]; this addAction [""Secure for Transport"", ""sqf\lcattach.sqf"", [], 1, false, true,"",""(((velocity _target) select 0) < 0.1) and (((velocity _target) select 1) < 0.1) and ((count (_target getvariable ""attachedobjs""))==0) and (({(((vehicle _x) != _target) and (_x != _this))} count (nearestobjects [_target, [""landvehicle"", ""camanbase""], 8]))>0)""]; this addAction [""Ready to Unload"", ""scripts\lcu\lcdetach.sqf"", [], 1, false, true,"",""(((velocity _target) select 0) < 0.1) and (((velocity _target) select 1) < 0.1) and ((count (_target getvariable ""attachedobjs""))>0)""]; this addaction [""Moor the Boat (disables motor)"", ""scripts\lcu\moorboat.sqf"", [], 0, false, true, "", ""((((getposatl _target) select 2)<6) or ((_target distance dockpos)<20) or ((_target distance dockpos2)<20)) and (not (_target getvariable ""moored"")) and (((velocity _target) select 0) < 0.1) and (((velocity _target) select 1) < 0.1)""]; this addaction [""Release Moorings (reenables motor)"", ""scripts\lcu\unmoorboat.sqf"", [], 0, false, true, "", ""(_target getvariable ""moored"""")""];  this addaction [""Go to deck"", ""scripts\lcu\lcgotodeck.sqf"", [], 0, false, true, "", ""_this in (crew _target)""];"] execVM "scripts\vehicle_respawn.sqf"

RPT ERROR LOG:

Error in expression <qf\lcattach.sqf", [], 1, false, true,","(((velocity _target) select 0) < 0.1) an>

Error position: <(((velocity _target) select 0) < 0.1) an>

Error Missing ]

Error in expression <qf\lcattach.sqf", [], 1, false, true,","(((velocity _target) select 0) < 0.1) an>

Error position: <(((velocity _target) select 0) < 0.1) an>

Error Missing ]

Edited by BelgarionNL

Share this post


Link to post
Share on other sites

veh = [this, 15, 120, 0, FALSE, FALSE, "this setvariable ['moored',false,true]; this setvariable ['attachedobjs',[],true]; this addAction ['Secure for Transport','sqf\lcattach.sqf',[],1,false,true,'','(((velocity _target) select 0) < 0.1) and (((velocity _target) select 1) < 0.1) and ((count (_target getvariable ''attachedobjs''))==0) and (({(((vehicle _x) != _target) and (_x != _this))} count (nearestobjects [_target,[''landvehicle'',''camanbase''],8]))>0)']; this addAction ['Ready to Unload', 'scripts\lcu\lcdetach.sqf',[],1,false,true,'','(((velocity _target) select 0) < 0.1) and (((velocity _target) select 1) < 0.1) and ((count (_target getvariable ''attachedobjs''))>0)']; this addaction ['Moor the Boat (disables motor)', 'scripts\lcu\moorboat.sqf',[],0,false,true,'','((((getposatl _target) select 2)<6) or ((_target distance dockpos)<20) or ((_target distance dockpos2)<20)) and (not (_target getvariable ''moored'')) and (((velocity _target) select 0) < 0.1) and (((velocity _target) select 1) < 0.1)']; this addaction ['Release Moorings (reenables motor)', 'scripts\lcu\unmoorboat.sqf',[],0,false,true,'','(_target getvariable ''moored'')']; this addaction ['Go to deck', 'scripts\lcu\lcgotodeck.sqf',[],0,false,true,'','_this in (crew _target)']"] execVM "scripts\vehicle_respawn.sqf"

:drinking:

Share this post


Link to post
Share on other sites
so what was wrong with it :P and you have these ' instead of " does that not matter

One ' == two ""

It is a way more clearly in my eyes and you have some wrong formatting errors in your code. It was enough work to fix it... now it is your turn to compare the codes... ;)

Share this post


Link to post
Share on other sites
veh = [this, 15, 120, 0, FALSE, FALSE, "this setvariable ['moored',false,true]; this setvariable ['attachedobjs',[],true]; this addAction ['Secure for Transport','sqf\lcattach.sqf',[],1,false,true,'','(((velocity _target) select 0) < 0.1) and (((velocity _target) select 1) < 0.1) and ((count (_target getvariable ''attachedobjs''))==0) and (({(((vehicle _x) != _target) and (_x != _this))} count (nearestobjects [_target,[''landvehicle'',''camanbase''],8]))>0)']; this addAction ['Ready to Unload', 'scripts\lcu\lcdetach.sqf',[],1,false,true,'','(((velocity _target) select 0) < 0.1) and (((velocity _target) select 1) < 0.1) and ((count (_target getvariable ''attachedobjs''))>0)']; this addaction ['Moor the Boat (disables motor)', 'scripts\lcu\moorboat.sqf',[],0,false,true,'','((((getposatl _target) select 2)<6) or ((_target distance dockpos)<20) or ((_target distance dockpos2)<20)) and (not (_target getvariable ''moored'')) and (((velocity _target) select 0) < 0.1) and (((velocity _target) select 1) < 0.1)']; this addaction ['Release Moorings (reenables motor)', 'scripts\lcu\unmoorboat.sqf',[],0,false,true,'','(_target getvariable ''moored'')']; this addaction ['Go to deck', 'scripts\lcu\lcgotodeck.sqf',[],0,false,true,'','_this in (crew _target)']"] execVM "scripts\vehicle_respawn.sqf"

:drinking:

my god, you didnt really format it like this did you??

Share this post


Link to post
Share on other sites

yes its still very much a work in progress. this is how I got it on armaholic and 2 be honest I have no idea how I can shorten it! :)

Share this post


Link to post
Share on other sites

Edit:

Oh man, that was a line if ive ever seen one...

try this instead, save the below as boats.sqf

_boat = _this select 0;

_boat setvariable ["moored", false, true];
_boat setvariable ["attachedobjs", [], true];
_boat addAction ["Secure for Transport", "scripts\lcu\lcattach.sqf", [], 1, false, true,"","(((velocity _target) select 0) < 0.1) and (((velocity _target) select 1) < 0.1) and ((count (_target getvariable ""attachedobjs""))==0) and (({(((vehicle _x) != _target) and (_x != _this))} count (nearestobjects [_target, [""landvehicle"", ""camanbase""], 8]))>0)"];
_boat addAction ["Ready to Unload", "scripts\lcu\lcdetach.sqf", [], 1, false, true,"","(((velocity _target) select 0) < 0.1) and (((velocity _target) select 1) < 0.1) and ((count (_target getvariable ""attachedobjs""))>0)"];
_boat addaction ["Moor the Boat (disables motor)", "scripts\lcu\moorboat.sqf", [], 0, false, true, "", "((((getposatl _target) select 2)<6) or ((_target distance dockpos)<20) or ((_target distance dockpos2)<20)) and (not (_target getvariable ""moored"")) and (((velocity _target) select 0) < 0.1) and (((velocity _target) select 1) < 0.1)"];
_boat addaction ["Release Moorings (reenables motor)", "scripts\lcu\unmoorboat.sqf", [], 0, false, true, "", "(_target getvariable ""moored"")"];
_boat addaction ["Go to deck", "scripts\lcu\lcgotodeck.sqf", [], 0, false, true, "", "_this in (crew _target)"];

Now place this in vehicle init:

_null = [this] execVM "boats.sqf";
veh = [this, 15, 120, 0, FALSE, FALSE, "[this] execVM 'boats.sqf'"] execVM "scripts\vehicle_respawn.sqf";

so instead of adding all the mess into the respawn init section, you have all the stuff saved in a seperate file and just run that file from the respawn init..

NOTE: I almost gave up on seperating that big long line, have not checked every condition used in the actions, im asuming it worked as is, and just the respawn section is edited here, along with this changed to _boat in top ofc.

I think since i remember Tophe uses setVehicleInit and processInitCommands, that all the actions will be good for all players this way.. only testing will show.

Edit2: You could also just replace [this] with this, and in boats.sqf remove the _boat = _this select 0; line and change all _boat to _this

Just to cut down on the script characters used, no real benefits...

Edited by Demonized
fixed bad instruction in Edit2.

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  

×