Jump to content
Sign in to follow this  
frosties

Set vehicle init when spawned?

Recommended Posts

Im using and edited HOG_MHQ script to spawn two mobile spawn points into my mission.

However, i would like the option to set the init field of these two vehicles.

Havent been able to do so myself and asking if somebody could be so kind in helping me?

The script for the spawning of the vehicles:

MHQ_Spawner2 = {

_Type = "ExA_RG31_M2_OD";

_Spawn_Pos = MHQ_Hpad2;

_Respawn_Time = 120;

MOBILE_HQ2 = createVehicle [_Type, _Spawn_Pos, [], 0, "NONE"]; publicVariable "MOBILE_HQ2";

MOBILE_HQ2 setDir ((getDir _Spawn_Pos));

_mhqsetup2 = [nil, MOBILE_HQ2, "per", rADDACTION, "Deploy Rally Point Bravo","HOG_scripts\HOG_MHQ\deploy\MHQ_deploy2.sqf"] call RE;

MOBILE_HQ2 addEventHandler ["killed", { [] spawn MHQ_REspawner2;}];

};

Share this post


Link to post
Share on other sites

Something like this:

MOBILE_HQ2 = createVehicle [_Type, _Spawn_Pos, [], 0, "NONE"]; publicVariable "MOBILE_HQ2";

MOBILE_HQ2 setVehicleInit " your init field code goes here ";

processInitCommands;

Share this post


Link to post
Share on other sites

AFAIK, the publicVariable is useless here. SetVehicleInit will be broadcasted on the net anyway.

Share this post


Link to post
Share on other sites

The publicVariable is a part of his spawn script, i've only added the red part!

Share this post


Link to post
Share on other sites
Something like this:

ive tried that already, and then the rest of the script wont load so nothing spawns.. really stuck at this issue.. :(

Share this post


Link to post
Share on other sites
ive tried that already, and then the rest of the script wont load so nothing spawns.. really stuck at this issue.. :(

Just tried it and it works just fine.

In MHQ_MHQ_functions.sqf i added:

MHQ_Spawner = {

_Type = "M1130_CV_EP1";

_Spawn_Pos = MHQ_Hpad;

_Respawn_Time = 120;

MOBILE_HQ = createVehicle [_Type, _Spawn_Pos, [], 0, "NONE"]; publicVariable "MOBILE_HQ";

MOBILE_HQ setVehicleInit "hint 'init code executed'";

processInitCommands;

MOBILE_HQ setDir ((getDir _Spawn_Pos));

_mhqsetup = [nil, MOBILE_HQ, "per", rADDACTION, "deploy MHQ","HOG_scripts\HOG_MHQ\deploy\MHQ_deploy.sqf"] call RE;

MOBILE_HQ addEventHandler ["killed", { [] spawn MHQ_REspawner;}];

};

Share this post


Link to post
Share on other sites

weird.. everytime i add it the vehicle never spawns. Like the script stops there and dont know what to do next..

Will try it again.

Well that script works, then it must be me that have an error in the script im trying to add into the vehicle init.

Trying to add a weapon in cargo just to see if it works:

MOBILE_HQ setVehicleInit "hint 'init code executed'; 0 = this addWeaponCargo ["ACE_CarlGustav_M3",1];";

processInitCommands;

This wont let the vehicle spawn, and i have tried many different codings... any ideas?

Edited by Frosties

Share this post


Link to post
Share on other sites

Remember to start arma with the -showScriptErrors parameter to catch script errors.

Share this post


Link to post
Share on other sites

Instead of the init stuff you could also do:

MOBILE_HQ = createVehicle [_Type, _Spawn_Pos, [], 0, "NONE"]; publicVariable "MOBILE_HQ";

MOBILE_HQ addWeaponCargoGlobal ["ACE_CarlGustav_M3",1];

Share this post


Link to post
Share on other sites

Thanks for the help guys!

However, i just recently noticed that this script isnt working on dedicated server, as its not JIP proofed.

Ive tried it as follows:

Start up the mission on a dedi server

Deploy the MHQ

Tried Undeploying/Re-deploying several times without error

I can teleport from base to MHQ without problem.

However..

Whenever i disconnect from the server and reconnect i cannot use the teleport or even undeploy the MHQ..

Any ideas about this?

Share this post


Link to post
Share on other sites

However..

Whenever i disconnect from the server and reconnect i cannot use the teleport or even undeploy the MHQ..

Any ideas about this?

You should post about this problem in the MHQ script authors thread so he can fix it!

Share this post


Link to post
Share on other sites

what if the units are not created and are editor placed, how would you put something into their init by using a trigger?

Share this post


Link to post
Share on other sites

Type name of unit into "Name" field and use them into statements of trigger.

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  

×