Jump to content
Sign in to follow this  
Praxtor

Eventhandlers and If, sleep, waituntil??

Recommended Posts

I want to know if is posible put inside of one Eventhandler one waituntil or while sintax like this;

Quote[/b] ]

pilotillo addEventHandler ["killed",{

   Helii SETDAMMAGE 0;

   deletevehicle pilotillo;

   "SoldierWPilot" createUnit [position leader group player, trip_HeliAU_W,"pilotillo=this;pilotillo moveindriver HeliAU", 1, "corporal"];

   deletegroup trip_HeliAU_W;      

   HeliA removeEventHandler ["killed", 0]}

    ];

This code works normaly but the problem if is i put one waitunitl inside of the code, it allways return error.

Quote[/b] ]

pilotillo addEventHandler ["killed",{

waituntil {

             dammage choper_1  > 0.5;

         };

   deletevehicle pilotillo;

   deletegroup trip_HeliAU_W;      

   HeliA removeEventHandler ["killed", 0]}

    ];

In wait until i allways get one error. Is the same if i put Sleep 5; i get error.

Some idea?

Thanks a lot.

Share this post


Link to post
Share on other sites

you cannot 'sleep' or 'waitUntil' a script that is run as an eventhandler as this script is synchronous.

you can however 'spawn' a 'script thread' from a script being run as an eventhandler.

So, have your eventHandler 'killed' call an sqf script called KilledEH.sqf.

in the 'KilledEH.sqf' have this script spawn a precompiled script (in the case where one is calling it alot) or execVM another script. In this 'other' script is where you do your 'waitUntil'.

eg. Get Killed -> KilledEH gets run -> KilledEH spawns a script thread to watch for my aliveness -> when alive, remove all my weapons...

got it?

Share this post


Link to post
Share on other sites

Also the WaitUntil part, needs to have the ; removed. So it looks like this:

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

       {

       ((dammage choper_1)  > 0.5)

       };

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  

×