Raised This Month: $ Target: $400
 0% 

Repeat set_task until a variable is true


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
justincase
Senior Member
Join Date: Dec 2008
Old 10-16-2009 , 14:20   Repeat set_task until a variable is true
Reply With Quote #1

Hello,
I have problems implementing a set_task, which gets repeated as long as a variable is false. This was what I tried first:
Code:
public func1(id, opid) {
    new params[2];
    params[0] = id;
    params[1] = opid;
    
    while (status == false) {
      set_task(5.0, "func2", 0, params, 2);
    }
}

public func2(id, opid) {
    client_print(0, print_chat, "IM IN FUNC2");
    client_print(0, print_chat, "IM IN FUNC2");
    client_print(0, print_chat, "IM IN FUNC2");
}
Result: CS freezes when calling func1().

Then I tried this:
Code:
public func1(id, opid) {
    new params[2];
    params[0] = id;
    params[1] = opid;
    
    set_task(5.0, "func2", 0, params, 2);
}

public func2(id, opid) {
    new params[2];
    params[0] = id;
    params[1] = opid;
    
    if (status == false) {
        set_task(5.0, "func2", 0, params, 2);
    }
    client_print(0, print_chat, "IM IN FUNC2");
    client_print(0, print_chat, "IM IN FUNC2");
    client_print(0, print_chat, "IM IN FUNC2");
}
Result: func2() did not get executed a single time.


The variable "status" is false when calling func1() and gets true in a specific event. The task should be repeated as long as status is false. I can't get it why my attempts are unsuccesfull for this.
justincase is offline
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:33.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode