Jump to content
Sign in to follow this  
masonkiller

Mine Simulation Script Not Returning Error, but not working either

Recommended Posts

I'm making a little script to simulate a minefield by causing explosions to randomly go off and kill each person who walks onto the trigger.

The trigger init:

mf = [thisList] execVM "minefield1.sqf";

And the script itself:

sleep 10;
_triggeractivatorlist = _this select 0;

while {(damage _x) < 1} do {

sleep random 15;

_mineexplosion = "Grenade" createVehicle (getPos _x);

} foreach _triggeractivatorlist;

Share this post


Link to post
Share on other sites

you should check the classes for grenades, as im pretty sure "grenade" isnt a class.

thats my guess, everything else looks good

Share this post


Link to post
Share on other sites

your script has many flaws in functionality, but that aside, you cannot end a while loop with a foreach command, however you can combine those 2.

// proper while loop:
while {something} do {
  hint "whatever";
  sleep 1;
};

// proper foreach loop/iteration:
{
  hint "whatever";
} foreach [array_content];

// combined while and foreach:
{
  while {something} do {
     sleep 1;
     hint "this will show hint and sleep for each person in turn, one after another";
  };
} foreach [array_content];

Edit: for what you are trying to do i would recomend you spawn a while loop foreach thisList:

{
  _mines = [_x] spawn {
     while {damagething} do {
        <something code>;
     };
  };
} foreach list;

spawn means a seperate script is launched, so the foreach would not wait for all the random 15 sleeps, but instead run 1 "script" with the sleep for all of the units inside trigger at same time.

Edited by Demonized

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  

×