Jump to content
Sign in to follow this  
avibird 1

Can't get this Script to initiate (run) in my mission! What am I forgetting!

Recommended Posts

I don't know why I can't get this SQF file to run in a mission I am working on. I have used it in the past with some domination edits. It is a basic def script that will spawn and respawn units in static fixed weapons around locations ie airport/bases. it was made by Titi called Group defense. I also use a Simple Vehicle Respawn Script v1.7 and Simple Guard Post Script 1.0 by Tophe. It works fine in a few domination missions but can't get the Group defense SQF to spawn the units in a new missions I am working on. here is the Titi script

/*
  Group defense
  By Titi
  DECEMBER 2011
*/

if (isServer) then {

   MoveGunner = {
       private ["_vcl","_deg","_dir","_unit"];
       _vcl = _this select 0;_deg = _this select 1;_dir = getdir _vcl;_unit = (gunner (vehicle _vcl));
       while {(alive _unit) && (alive _vcl)} do {
           _unit setformdir _dir +((random -(_deg)+(_deg/2)));
           sleep 3+(random 6);
       };
   };

   ReplaceGunner = {
       private ["_unit","_gun","_grp"];
    _unit = _this select 0;_gun = _this select 1;_grp = _this select 2;
    while {alive _unit} do {sleep 1};
	if !(alive _unit) then {
	   sleep 120+random 60;
          _unit = _grp createUnit ["US_Soldier_EP1", getPos _gun, [], 0.6, "form"];
          _unit assignAsGunner _gun;
          _unit moveInGunner _gun;
          _unit addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}];
      [_unit,_gun,_grp] spawn ReplaceGunner;
   };
   };

   ReloadGun = {
       private ["_gun"];
       _gun = _this select 0;
       while {alive _gun} do {
         sleep 180;
         _gun setVehicleAmmo 1;
    };
   };


  _grp = createGroup west;

  gunner_1 = _grp createUnit ["US_Soldier_EP1", getPos gun_1, [], 0.6, "form"];
  gunner_1 assignAsGunner gun_1;
  gunner_1 moveInGunner gun_1;
  gunner_1 setVariable ["BIS_noCoreConversations", true];
  gunner_1 setSkill 0.4+(random 0.3);
  gunner_1 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}];
  if (gunner_1 hasWeapon "NVGoggles") then {gunner_1 removeWeapon "NVGoggles"};
  gunner_1 addWeapon "NVGoggles";
  sleep 0.3;

  gunner_2 = _grp createUnit ["US_Soldier_EP1", getPos gun_2, [], 0.6, "form"];
  gunner_2 assignAsGunner gun_2;
  gunner_2 moveInGunner gun_2;
  gunner_2 setVariable ["BIS_noCoreConversations", true];
  gunner_2 setSkill 0.4+(random 0.3);
  gunner_2 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}];
  if (gunner_2 hasWeapon "NVGoggles") then {gunner_2 removeWeapon "NVGoggles"};
  gunner_2 addWeapon "NVGoggles";
  sleep 0.3;

  gunner_3 = _grp createUnit ["US_Soldier_EP1", getPos gun_3, [], 0.6, "form"];
  gunner_3 assignAsGunner gun_3;
  gunner_3 moveInGunner gun_3;
  gunner_3 setVariable ["BIS_noCoreConversations", true];
  gunner_3 setSkill 0.4+(random 0.3);
  gunner_3 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}];
  if (gunner_3 hasWeapon "NVGoggles") then {gunner_3 removeWeapon "NVGoggles"};
  gunner_3 addWeapon "NVGoggles";
  sleep 0.3;

  gunner_4 = _grp createUnit ["US_Soldier_EP1", getPos gun_4, [], 0.6, "form"];
  gunner_4 assignAsGunner gun_4;
  gunner_4 moveInGunner gun_4;
  gunner_4 setVariable ["BIS_noCoreConversations", true];
  gunner_4 setSkill 0.4+(random 0.3);
  gunner_4 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}];
  if (gunner_4 hasWeapon "NVGoggles") then {gunner_4 removeWeapon "NVGoggles"};
  gunner_4 addWeapon "NVGoggles";
  sleep 0.3;

  gunner_5 = _grp createUnit ["US_Soldier_EP1", getPos gun_5, [], 0.6, "form"];
  gunner_5 assignAsGunner gun_5;
  gunner_5 moveInGunner gun_5;
  gunner_5 setVariable ["BIS_noCoreConversations", true];
  gunner_5 setSkill 0.4+(random 0.3);
  gunner_5 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}];
  if (gunner_5 hasWeapon "NVGoggles") then {gunner_5 removeWeapon "NVGoggles"};
  gunner_5 addWeapon "NVGoggles";
  sleep 0.3;

  gunner_6 = _grp createUnit ["US_Soldier_EP1", getPos tow_1, [], 0.6, "form"];
  gunner_6 assignAsGunner tow_1;
  gunner_6 moveInGunner tow_1;
  gunner_6 setVariable ["BIS_noCoreConversations", true];
  gunner_6 setSkill 0.4+(random 0.3);
  gunner_6 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}];
  if (gunner_6 hasWeapon "NVGoggles") then {gunner_6 removeWeapon "NVGoggles"};
  gunner_6 addWeapon "NVGoggles";
  sleep 0.3;

  gunner_7 = _grp createUnit ["US_Soldier_EP1", getPos tow_2, [], 0.6, "form"];
  gunner_7 assignAsGunner tow_2;
  gunner_7 moveInGunner tow_2;
  gunner_7 setVariable ["BIS_noCoreConversations", true];
  gunner_7 setSkill 0.4+(random 0.3);
  gunner_7 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}]; 
  if (gunner_7 hasWeapon "NVGoggles") then {gunner_7 removeWeapon "NVGoggles"};
  gunner_7 addWeapon "NVGoggles";
  sleep 0.3;

  gunner_8 = _grp createUnit ["US_Soldier_EP1", getPos tow_3, [], 0.6, "form"];
  gunner_8 assignAsGunner tow_3;
  gunner_8 moveInGunner tow_3;
  gunner_8 setVariable ["BIS_noCoreConversations", true];
  gunner_8 setSkill 0.4+(random 0.3);
  gunner_8 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}]; 
  if (gunner_8 hasWeapon "NVGoggles") then {gunner_8 removeWeapon "NVGoggles"};
  gunner_8 addWeapon "NVGoggles";
  sleep 0.3;  

  gunner_9 = _grp createUnit ["US_Soldier_EP1", getPos AA_1, [], 0.6, "form"];
  gunner_9 assignAsGunner AA_1;
  gunner_9 moveInGunner AA_1;
  gunner_9 setVariable ["BIS_noCoreConversations", true];
  gunner_9 setSkill 0.4+(random 0.3);
  gunner_9 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}]; 
  if (gunner_9 hasWeapon "NVGoggles") then {gunner_9 removeWeapon "NVGoggles"};
  gunner_9 addWeapon "NVGoggles";
  sleep 0.3; 

  gunner_10 = _grp createUnit ["US_Soldier_EP1", getPos AA_2, [], 0.6, "form"];
  gunner_10 assignAsGunner AA_2;
  gunner_10 moveInGunner AA_2;
  gunner_10 setVariable ["BIS_noCoreConversations", true];
  gunner_10 setSkill 0.4+(random 0.3);
  gunner_10 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}]; 
  if (gunner_10 hasWeapon "NVGoggles") then {gunner_10 removeWeapon "NVGoggles"};
  gunner_10 addWeapon "NVGoggles";
  sleep 0.3; 

  gunner_11 = _grp createUnit ["US_Soldier_EP1", getPos mg_1, [], 0.6, "form"];
  gunner_11 assignAsGunner mg_1;
  gunner_11 moveInGunner mg_1;
  gunner_11 setVariable ["BIS_noCoreConversations", true];
  gunner_11 setSkill 0.4+(random 0.3);
  gunner_11 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}]; 
  if (gunner_11 hasWeapon "NVGoggles") then {gunner_11 removeWeapon "NVGoggles"};
  gunner_11 addWeapon "NVGoggles";
  sleep 0.3; 

  gunner_12 = _grp createUnit ["US_Soldier_EP1", getPos mg_2, [], 0.6, "form"];
  gunner_12 assignAsGunner mg_2;
  gunner_12 moveInGunner mg_2;
  gunner_12 setVariable ["BIS_noCoreConversations", true];
  gunner_12 setSkill 0.4+(random 0.3);
  gunner_12 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}]; 
  if (gunner_12 hasWeapon "NVGoggles") then {gunner_12 removeWeapon "NVGoggles"};
  gunner_12 addWeapon "NVGoggles";
  sleep 0.3; 

  gunner_13 = _grp createUnit ["US_Soldier_EP1", getPos mg_3, [], 0.6, "form"];
  gunner_13 assignAsGunner mg_3;
  gunner_13 moveInGunner mg_3;
  gunner_13 setVariable ["BIS_noCoreConversations", true];
  gunner_13 setSkill 0.4+(random 0.3);
  gunner_13 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}]; 
  if (gunner_13 hasWeapon "NVGoggles") then {gunner_13 removeWeapon "NVGoggles"};
  gunner_13 addWeapon "NVGoggles"; 
  sleep 0.3; 

  gunner_14 = _grp createUnit ["US_Soldier_EP1", getPos mg_4, [], 0.6, "form"];
  gunner_14 assignAsGunner mg_4;
  gunner_14 moveInGunner mg_4;
  gunner_14 setVariable ["BIS_noCoreConversations", true];
  gunner_14 setSkill 0.4+(random 0.3);
  gunner_14 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}];
  if (gunner_14 hasWeapon "NVGoggles") then {gunner_14 removeWeapon "NVGoggles"};
  gunner_14 addWeapon "NVGoggles";
  sleep 0.3; 

  _pos = [(getPos bunker_1 select 0)+8,(getPos bunker_1 select 1)-8,0]; 
  guard_1 = _grp createUnit ["US_Soldier_MG_EP1", _pos, [], 0.6, "form"];
  guard_1 setVariable ["BIS_noCoreConversations", true];
  guard_1 setSkill 0.4+(random 0.3);
  if (guard_1 hasWeapon "NVGoggles") then {guard_1 removeWeapon "NVGoggles"};
  guard_1 addWeapon "NVGoggles";
  guard_1 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}];
  guard_1 setPos [(getPos bunker_1 select 0),(getPos bunker_1 select 1),2.80]; 
  dostop guard_1;
  guard_1 setUnitPos "middle";
  sleep 0.3;

  _pos2 = [(getPos bunker_2 select 0)+8,(getPos bunker_2 select 1)-8,0]; 
  guard_2 = _grp createUnit ["US_Soldier_MG_EP1", _pos2, [], 0.6, "form"];
  guard_2 setVariable ["BIS_noCoreConversations", true];
  guard_2 setSkill 0.4+(random 0.3);
  if (guard_2 hasWeapon "NVGoggles") then {guard_2 removeWeapon "NVGoggles"};
  guard_2 addWeapon "NVGoggles";
  guard_2 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}];
  guard_2 setPos [(getPos bunker_2 select 0),(getPos bunker_2 select 1),2.80]; 
  dostop guard_2;
  guard_2 setUnitPos "middle";
  sleep 0.3;

  _pos3 = [(getPos bunker_3 select 0)+8,(getPos bunker_3 select 1)-8,0]; 
  guard_3 = _grp createUnit ["US_Soldier_MG_EP1", _pos3, [], 0.6, "form"];
  guard_3 setVariable ["BIS_noCoreConversations", true];
  guard_3 setSkill 0.4+(random 0.3);
  if (guard_3 hasWeapon "NVGoggles") then {guard_3 removeWeapon "NVGoggles"};
  guard_3 addWeapon "NVGoggles";
  guard_3 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}];
  guard_3 setPos [(getPos bunker_3 select 0),(getPos bunker_3 select 1),2.80]; 
  dostop guard_3;
  guard_3 setUnitPos "middle";
  sleep 0.3;

  _pos4 = [(getPos bunker_4 select 0)+8,(getPos bunker_4 select 1)-8,0]; 
  guard_4 = _grp createUnit ["US_Soldier_MG_EP1", _pos4, [], 0.6, "form"];
  guard_4 setVariable ["BIS_noCoreConversations", true];
  guard_4 setSkill 0.4+(random 0.3);
  if (guard_4 hasWeapon "NVGoggles") then {guard_4 removeWeapon "NVGoggles"};
  guard_4 addWeapon "NVGoggles";
  guard_4 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}];
  guard_4 setPos [(getPos bunker_4 select 0),(getPos bunker_4 select 1),2.80]; 
  dostop guard_4;
  guard_4 setUnitPos "middle";
  sleep 0.3;

  sniper_1 = _grp createUnit ["US_Soldier_SniperH_EP1", getPos light1, [], 0.6, "form"];
  sniper_1 setVariable ["BIS_noCoreConversations", true];
  sniper_1 setSkill 0.4+(random 0.3);
  if (sniper_1 hasWeapon "NVGoggles") then {sniper_1 removeWeapon "NVGoggles"};
  sniper_1 addWeapon "NVGoggles";
  sniper_1 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}];
  sniper_1 setPos [(getPos light1 select 0),(getPos light1 select 1),20.10]; 
  dostop sniper_1;  
  sniper_1 setUnitPos "auto";
  sleep 0.3;

  sniper_2 = _grp createUnit ["US_Soldier_SniperH_EP1", getPos light5, [], 0.6, "form"];
  sniper_2 setVariable ["BIS_noCoreConversations", true];
  sniper_2 setSkill 0.4+(random 0.3);
  if (sniper_2 hasWeapon "NVGoggles") then {sniper_2 removeWeapon "NVGoggles"};
  sniper_2 addWeapon "NVGoggles";
  sniper_2 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}];
  sniper_2 setPos [(getPos light5 select 0),(getPos light5 select 1),20.10]; 
  dostop sniper_2;  
  sniper_2 setUnitPos "auto";
  sleep 0.3;

  sclight_1 = _grp createUnit ["US_Soldier_EP1", getPos light1, [], 0.6, "form"];
  sclight_1 assignAsGunner searchlight_1;
  sclight_1 moveInGunner searchlight_1;
  sclight_1 setVariable ["BIS_noCoreConversations", true];
  sclight_1 setSkill 0.4+(random 0.3);
  sclight_1 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}];
  sleep 0.3;

  sclight_2 = _grp createUnit ["US_Soldier_EP1", getPos light5, [], 0.6, "form"];
  sclight_2 assignAsGunner searchlight_2;
  sclight_2 moveInGunner searchlight_2;
  sclight_2 setVariable ["BIS_noCoreConversations", true];
  sclight_2 setSkill 0.4+(random 0.3);
  sclight_2 addEventHandler ["killed",{_this execVM "scripts\dead.sqf"}];
  sleep 0.3;

  (leader _grp) setRank "LIEUTENANT";

  gun_1 allowDamage false;
  [gun_1,180] spawn MoveGunner;
  [gun_1] spawn ReloadGun;
  [gunner_1,gun_1,_grp] spawn ReplaceGunner;
  sleep 0.3;

  gun_2 allowDamage false;
  [gun_2,180] spawn MoveGunner;
  [gun_2] spawn ReloadGun;
  [gunner_2,gun_2,_grp] spawn ReplaceGunner;
  sleep 0.3;

  gun_3 allowDamage false;
  [gun_3,360] spawn MoveGunner;
  [gun_3] spawn ReloadGun;
  [gunner_3,gun_3,_grp] spawn ReplaceGunner;
  sleep 0.3;

  gun_4 allowDamage false;
  [gun_4,180] spawn MoveGunner;
  [gun_4] spawn ReloadGun;
  [gunner_4,gun_4,_grp] spawn ReplaceGunner;
  sleep 0.3;

  gun_5 allowDamage false;
  [gun_5,180] spawn MoveGunner;
  [gun_5] spawn ReloadGun;
  [gunner_5,gun_5,_grp] spawn ReplaceGunner;
  sleep 0.3;

  tow_1 allowDamage false;
  [tow_1,360] spawn MoveGunner;
  [tow_1] spawn ReloadGun;
  [gunner_6,tow_1,_grp] spawn ReplaceGunner;

  tow_2 allowDamage false;
  [tow_2,180] spawn MoveGunner;
  [tow_2] spawn ReloadGun;
  [gunner_7,tow_2,_grp] spawn ReplaceGunner;
  sleep 0.3;

  tow_3 allowDamage false;
  [tow_3,180] spawn MoveGunner;
  [tow_3] spawn ReloadGun;
  [gunner_8,tow_3,_grp] spawn ReplaceGunner;
  sleep 0.3;

  aa_1 allowDamage false;
  [aa_1,180] spawn MoveGunner;
  [aa_1] spawn ReloadGun;
  [gunner_9,aa_1,_grp] spawn ReplaceGunner;
  sleep 0.3;

  aa_2 allowDamage false;
  [aa_2,180] spawn MoveGunner;
  [aa_2] spawn ReloadGun;
  [gunner_10,aa_2,_grp] spawn ReplaceGunner;
  sleep 0.3;

  mg_1 allowDamage false;
  [mg_1,45] spawn MoveGunner;
  [mg_1] spawn ReloadGun;
  [gunner_11,mg_1,_grp] spawn ReplaceGunner;
  sleep 0.3;

  mg_2 allowDamage false;
  [mg_2,45] spawn MoveGunner;
  [mg_2] spawn ReloadGun;
  [gunner_12,mg_2,_grp] spawn ReplaceGunner;
  sleep 0.3;

  mg_3 allowDamage false;
  [mg_3,45] spawn MoveGunner;
  [mg_3] spawn ReloadGun;
  [gunner_13,mg_3,_grp] spawn ReplaceGunner;
  sleep 0.3;

  mg_3 allowDamage false;
  [mg_3,45] spawn MoveGunner;
  [mg_3] spawn ReloadGun;
  [gunner_14,mg_3,_grp] spawn ReplaceGunner;
  sleep 0.3;


};

if (true) exitwith {}; 

There is nothing in the mission init or description that I see that needs to call the script to run. Help. I would love for this to work I can add the units into the static weapons via editor but after they are dead can't get the def weapons back up without this script): Help thanks Avibird

Edited by AVIBIRD 1

Share this post


Link to post
Share on other sites

AVIBIRD, how are you calling this script? Do you have the dead.sqf script in your scripts folder? Do you have the gun_1 etc placed?

How about the bunker_1 etc? All the tow's, all the AA's?

Do you have -showScriptErrors enabled?

There is nothing in the mission init or description that I see that needs to call the script to run.

Do you mean you're not even executing this?

Edited by panther42

Share this post


Link to post
Share on other sites

At the park with my kids I think I had the dead sqf as well. How should I call the script in? I thought initiate when the mission starts. Do you think I need to call it via trigger in the mission init. I still get confused on thisf

Edited by AVIBIRD 1

Share this post


Link to post
Share on other sites

You need to call it with execVM.

Init sqf version:

[] execVM "dead.sqf";

In-mission version:

nul = [] execVM "dead.sqf";

Share this post


Link to post
Share on other sites

What do you mean inti sqf version vs mission version? In the two domination edits there is nothing in the mission init that call this script and it works fine. I am lost when you say inti version vs mission. Just when you think you know how this whole scripting/coding works things like this make you want to throw your pc in the water lol

Share this post


Link to post
Share on other sites

Well the script doesn't necessarily have to be called in the init.sqf.

The major difference between calling a script in the init.sqf and calling it in the mission (via trigger or init fields) is that you don't include a script handle (the nul i put infront of the script is a script handle).

Just make an init.sqf and include the line I provide above in it, and see if it works.

Share this post


Link to post
Share on other sites

I kinda knew that but like I said I have it working fine in two other domination missions and there is nothing calling the script in via mission inti or in game with trigger. This is why I am a little lost on this. When I get home with try with both inti call in and mission call in thru trigger/marker. Thanks will let you know.

Share this post


Link to post
Share on other sites

So I added the [] execVM "dead.sqf"; to my mission inti. sqf no luck then added the nul = [] execVM "dead.sqf"; in a inti box of a object in the mission and no luck

this is the dead.sqf

_unit = _this select 0;

if (isServer) then {
  if (_unit isKindOf "Man") then {
sleep 30;
hideBody _unit;
sleep 4;
deleteVehicle _unit;
  };
}; 

I have both of the SQF files in a script folder inside my mission folder. I know that the scripts work because I have them in other missions. I am so lost right now WTF. Help please ):

Share this post


Link to post
Share on other sites

have you placed the gamelogics for spawning locations on the map?

Share this post


Link to post
Share on other sites

NOT dead.sqf AVIBIRD 1, run the same thing, but I thought your script was called GroupDefense.sqf or whatever you named the one in the OP.

dead.sqf is run via eventHandler when units get killed. It should be in a folder called scripts

If both are in the scripts folder, run this:

[] execVM "scripts\GroupDefense.sqf"; or whatever your OP script is called

If all else fails, post a link to your mission and we'll dissect it!

Edited by panther42

Share this post


Link to post
Share on other sites

lol I will try right now but in the other two missions the the scripts work fine no [] execVM "scripts\GroupDefense.sqf do i see in the inti sqf and no where in the mission do i see nul = [] execVM "scripts\GroupDefense.sqf.

I am going to test right now

Share this post


Link to post
Share on other sites

Well this could be done via trigger, wayPoint, init of an object, etc...

If you post one that works, and the one you are trying to get working, we'll get this kicked

Share this post


Link to post
Share on other sites

Panther If I was gay I would kiss you right now lol Thank you it works (: the funny thing is that the two other missions that uses Titi Group defense.sqf does not have the call in within the inti.sqf OR in the mission itself using nul = [] execVM "";

Sometimes looking at all this coding shit and trying to make things work when you have no real clue how to read the codelines will make you nuts because most of the time it is a very simple thing that is wrong. Thank god for this thread and people like you. I do try to do my part for others if I can help! thank guys. I am sure I will have more issues. The good news is my mission is almost done for release. It is a domination/insurgency/warefare type mission that can be played solo, 12 player coop or 12 vs 2 player vs player.

Share this post


Link to post
Share on other sites

I'm glad you got it working. The most important part is to learn as you go. Almost everyone on here needs some help at one time or another. Never hesitate to ask...

If I could see your mission that works, I could show you how it's done so you understand. If not, we'll go on from here.

Good Luck

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  

×