• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] YSI\y_timers problem [ solved ]
#1
Photo 
How to stop a timer. The " stop x " doesn't work. It is a BUG or I don't use it right ?



Code:
#include <a_samp>

#include <YSI_Coding\y_timers>



main()

{

    print("Start Timer Test2");

    defer Test2();

}





timer Test1[10000]()

{

    print(" Why still working ? Why calling this timer 2x ?");

    return 1;

}



timer Test2[5000]()

{

    print(" Timer Test2 5 sec ");

    defer Test3();

    defer Test1();

    return 1;

}



timer Test3[2000]()

{

    print(" Timer Test3 6 sec ");

    stop Test1();  // It seems that simply calls the function instantly and not stoping anything ... That's why calling the timer 2x

    return 1;

}



https://tinypic.host/image/LqSj4



And now I'm using qanwo with the latest release from YSI and still exact the same problem.







Code:
#include <open.mp>

#define YSI_NO_HEAP_MALLOC

#include <YSI_Coding\y_timers>



timer Test1[10000]()

{

    print(" Why still working ? Why calling this timer 2x ?");

    return 1;

}



timer Test3[2000]()

{

    print(" Timer Test3 6 sec ");

    stop Timer:Test1();  // It seems that simply calls the function instantly and not stoping anything ... That's why calling the timer 2x

    return 1;

}



timer Test2[5000]()

{

    print(" Timer Test2 5 sec ");

    defer Test3();

    defer Test1();

    return 1;

}



main()

{

    print("Start Timer Test2");

    defer Test2();

}



https://tinypic.host/image/LzMcb





Now I really think that I'm using it wrong because not even the normal way doesn't work.



Code:
#include <a_samp>



main()

{

    print(" Start Timer_Test2 5 sec");

    SetTimer("Timer_Test2", 5000, false);

}



forward Timer_Test1();

forward Timer_Test2();

forward Timer_Test3();



public Timer_Test1()

{

    print(" Why still working ? Why calling this timer 2x ?");

    return 1;

}



public Timer_Test2()

{

    print(" Timer Test2 5 sec ");

   

    SetTimer("Timer_Test3", 6000, false);

    SetTimer("Timer_Test1", 10000, false);



    return 1;

}



public Timer_Test3()

{

    print(" Timer Test3 6 sec ");

    KillTimer(Timer_Test1());

    return 1;

}





I found the right way. 





Code:
#include <a_samp>



new test1;

new test2;

new test3;



main()

{

    print(" Start Timer_Test2 5 sec");

    test2 = SetTimer("Timer_Test2", 5000, false);

}



forward Timer_Test1();

forward Timer_Test2();

forward Timer_Test3();



public Timer_Test1()

{

    print(" Why still working ? Why calling this timer 2x ?");

    return 1;

}



public Timer_Test2()

{

    print(" Timer Test2 5 sec ");



    test3 = SetTimer("Timer_Test3", 6000, false);

    test1 = SetTimer("Timer_Test1", 10000, false);



    return 1;

}



public Timer_Test3()

{

    print(" Timer Test3 6 sec ");

    KillTimer(test1);

    return 1;

}




Like I thought... I wasn't use it right ! Everything work just perfect ! 
This is how it works:


Code:
#include <a_samp>
#define YSI_NO_HEAP_MALLOC
#include <YSI_Coding\y_timers>

new Timer:test;

timer Test1[10000]()
{
    print(" Why still working ? Why calling this timer 2x ?");
    return 1;

}

timer Test3[2000]()
{
    print(" Timer Test3 6 sec ");
    stop Timer:test;  // It seems that simply calls the function instantly and not stoping anything ... That's why calling the timer 2x
    return 1;

}

timer Test2[5000]()
{
    print(" Timer Test2 5 sec ");
    defer Timer:Test3();
   
    test = defer Timer:Test1();
    return 1;

}

main()
{
    print("Start Timer Test2 xx");
    defer Timer:Test2();
}
  Reply


Forum Jump: