Results 1 to 6 of 6

Thread: Alternative to using Sleep command in a function

  1. #1

    Smile Alternative to using Sleep command in a function

    Bellow is my function in which the sleep command isn't working, and I need some delay's to get it just right. What alternative is there? I've tried using a time delay but thats not working too well either, any ideas?

    Code:
    civim_fnc_suicide = {    private ["_target","_player","_delayTimer","_delay"];
        _target = _this select 0;
        _player = _this select 1;
        _target lookAt _player;
        _target disableAI "ANIM";
        _target disableAI "MOVE";
        _target disableAI "TARGET";
        _target disableAI "AUTOTARGET";
        if (civim_debug) then {format ["DEBUG: %1 is commiting suicide. (Global)", (name _target)] call CBA_fnc_systemChat};
        _target addWeapon "Colt1911";
        [-2, {_target switchMove "ActsPercMstpSnonWpstDnon_suicide1B"}] call CBA_fnc_globalExecute;
        if (!isMultiplayer) then {_target switchMove "ActsPercMstpSnonWpstDnon_suicide1B"};
    
    
        _delayTimer = time;
       _delay = 4;
        waituntil {(time > (_delaytimer + _delay))};
        sleep 4;
        [_target, "m1911"] call CBA_fnc_globalSay3d;
        _delayTimer = time;
        _delay = 2;
        waituntil {(time > (_delaytimer + _delay))};
        sleep 2;
        _target setDammage 1;
    };

  2. #2
    Gunnery Sergeant Mikie boy's Avatar
    Join Date
    Jun 20 2009
    Location
    United Kingdoom
    Posts
    472
    activate the script with "spawn" instead of "call" is one way to do it...

    call ignores (so to speak) the sleep
    [FOCK] Mikie J

    Looking for New Players at Fockersteam
    http://fockers.moonfruit.com/

    A2/OA
    COOP Most Wanted - [Fockers] Most Wanted Co-x v07-09-2012
    Fock IED - http://www.armaholic.com/page.php?id...highlight=FOCK
    Fock Recruit/Group Management - http://www.armaholic.com/page.php?id=20580

    A3
    TvTCache Hunt - [FOCK]ers Cache Hunt TvT-x [ALPHA]
    Scripting Tutotial -http://www.armaholic.com/page.php?id=20465#comments
    Fock Recruit/Group Management - http://www.armaholic.com/page.php?id=19041

  3. #3
    Quote Originally Posted by Mikie boy View Post
    call ignores (so to speak) the sleep
    Not at all.
    Call command can call functions with sleep in them, the problem the OP is having is that he is calling the function within a non-schedualed enviroment, say, within a trigger, event handler or init commands.

    If you really need to use sleep in one of these situations use SPAWN instead of CALL!
    Same goes with waitUntil, and with loops such as While, these will be limited to 10.000 itenerations.
    Proud community admin/member of The Tour of Teamrespawn

  4. #4
    Quote Originally Posted by neokika View Post
    Not at all.
    Call command can call functions with sleep in them, the problem the OP is having is that he is calling the function within a non-schedualed enviroment, say, within a trigger, event handler or init commands.

    If you really need to use sleep in one of these situations use SPAWN instead of CALL!
    Same goes with waitUntil, and with loops such as While, these will be limited to 10.000 itenerations.
    As well, he does not have a return in this method, so using call is unnecessary (by the looks of it, this script is not time dependent (like some script waiting for a return value of some calculation).

  5. #5
    Awesome guys thanks

  6. #6
    Hi guys i have the same problem but i need my script to be time sensitive.

    (I need Projectile coordinates as soon as its shot out from the weapon, all other scripting catches the projectile way after its fired except call.

    Can a delay be done in a call function?

Similar Threads

  1. Can you add a sleep command for a script that was made already!
    By AVIBIRD 1 in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 5
    Last Post: Nov 23 2011, 06:27
  2. A little problem with the sleep function.
    By VonNexus in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 20
    Last Post: Sep 6 2011, 19:26
  3. Sleep Function (wait time) in script
    By McSpuds in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 1
    Last Post: Sep 16 2010, 15:03
  4. sleep command
    By Rahul in forum OFP : MISSION EDITING & SCRIPTING
    Replies: 1
    Last Post: Sep 12 2009, 09:03
  5. startLoadingScreen seems to freeze scripts and sleep command has no effect
    By MulleDK19 in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 2
    Last Post: Jun 6 2009, 11:31

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •