About y_timers
#1

How to stop a task?
For ex. task blabla[10000]()
Reply
#2

Please post the timer.
Reply
#3

Read through this! This was posted by RIDE2DAY on the y_timers thread. This might help

Код:
/* Set all cells to -1 */ 
new Timer:myTimer[MAX_PLAYERS] = {Timer:-1, ...}; 

/* Start the timer */ 
CMD:mycommand(playerid, params[]) 
{ 
    myTimer[playerid] = repeat MyOwnFunction(playerid); 
    /* MyOwnFunction will be called 1 second after we type the 
    command, due the delay parameter from timer, that's how it works. */ 
    return 1; 
} 

/* Declare MyOwnFunction as a timer */ 
timer MyOwnFunction[1000](playerid) 
{ 
    printf("The player who started timer %d has the ID %d.", _:myTimer[playerid], playerid); 
    // This function will print the same message every second. 
} 

/* Stop the timer */ 
COMMAND:stoptimer(playerid, params[]) 
{ 
    if(myTimer[playerid] != Timer:-1) 
    { 
        stop myTimer[playerid]; 
        myTimer[playerid] = Timer:-1; 
    } 
    else 
    { 
        // The timer isn't running. 
    } 
    return 1; 
}
Reply
#4

Quote:
Originally Posted by JessThompson
Посмотреть сообщение
Please post the timer.
PHP код:
task autoMoneyBag[1200000]()
{
    if(
Moneybagid != -1)
    {
        new 
MoneybagID Moneybagid;
        
DestroyPickup(moneyBagInfo[MoneybagID][bagID]);
        
//DestroyDynamic3DTextLabel(moneyBagInfo[MoneybagID][bagLabel]);
        
Moneybagid = -1;
        
MessageAll(-1"{cafca6}[Moneybag] {FFFFFF}Shit! The event has ended, no one found the Moneybag");
    }
    else
    {
        new 
randomBag random(MAX_BAG_LOCATIONS), world moneyBagInfo[randomBag][bagWorld];
 
        
moneyBagInfo[randomBag][bagID] = CreatePickup(155023moneyBagInfo[randomBag][bagXYZ][0], moneyBagInfo[randomBag][bagXYZ][1], moneyBagInfo[randomBag][bagXYZ][2], world);
        
//moneyBagInfo[randomBag][bagLabel] = CreateDynamic3DTextLabel("[Moneybag]", COLOR_YELLOW, moneyBagInfo[randomBag][bagXYZ][0], moneyBagInfo[randomBag][//bagXYZ][1], moneyBagInfo[randomBag][bagXYZ][2] - 0.1, 40.0, .worldid = 5, .interiorid = 13);
        
Moneybagid randomBag;        
        
MessageAll(-1"{cafca6}[Moneybag] {FFFFFF} A Moneybag is hidden inside {FFDC2E}%s{FFFFFF}!"moneyBagInfo[randomBag][bagTitle]);
    }

Reply
#5

To my knowledge I don't think you can stop tasks so you will need to convert it into a timer, I have done this below for ya'

Код:
/* Place this at the top of yo' script */
new Timer:AutoMoneyBag = {Timer:-1, ...}; 

/* Place this where you want the timer to start */ 

AutoMoneyBag = repeat autoMoneyBagTimer(); 

/* Replace this with your old function */

timer autoMoneyBagTimer[TIME HERE IN MS]() 
{ 
    if(Moneybagid != -1) 
    { 
        new MoneybagID = Moneybagid; 
        DestroyPickup(moneyBagInfo[MoneybagID][bagID]); 
        //DestroyDynamic3DTextLabel(moneyBagInfo[MoneybagID][bagLabel]); 
        Moneybagid = -1; 
        MessageAll(-1, "{cafca6}[Moneybag] {FFFFFF}Shit! The event has ended, no one found the Moneybag"); 
    } 
    else 
    { 
        new randomBag = random(MAX_BAG_LOCATIONS), world = moneyBagInfo[randomBag][bagWorld]; 
  
        moneyBagInfo[randomBag][bagID] = CreatePickup(1550, 23, moneyBagInfo[randomBag][bagXYZ][0], moneyBagInfo[randomBag][bagXYZ][1], moneyBagInfo[randomBag][bagXYZ][2], world); 
        //moneyBagInfo[randomBag][bagLabel] = CreateDynamic3DTextLabel("[Moneybag]", COLOR_YELLOW, moneyBagInfo[randomBag][bagXYZ][0], moneyBagInfo[randomBag][//bagXYZ][1], moneyBagInfo[randomBag][bagXYZ][2] - 0.1, 40.0, .worldid = 5, .interiorid = 13); 
        Moneybagid = randomBag;         
        MessageAll(-1, "{cafca6}[Moneybag] {FFFFFF} A Moneybag is hidden inside {FFDC2E}%s{FFFFFF}!", moneyBagInfo[randomBag][bagTitle]); 
    } 
} 

/* Place this where you want to stop said timer */ 

if(AutoMoneyBag!= Timer:-1) 
{ 
    stop AutoMoneyBag; 
    AutoMoneyBag= Timer:-1; 
} 
else 
{ 
    printf("The timer is already long gone!")
}
Reply
#6

Quote:
Originally Posted by JessThompson
Посмотреть сообщение
To my knowledge I don't think you can stop tasks so you will need to convert it into a timer, I have done this below for ya'

Код:
/* Place this at the top of yo' script */
new Timer:AutoMoneyBag = {Timer:-1, ...}; 

/* Place this where you want the timer to start */ 

AutoMoneyBag = repeat autoMoneyBagTimer(); 

/* Replace this with your old function */

timer autoMoneyBagTimer[TIME HERE IN MS]() 
{ 
    if(Moneybagid != -1) 
    { 
        new MoneybagID = Moneybagid; 
        DestroyPickup(moneyBagInfo[MoneybagID][bagID]); 
        //DestroyDynamic3DTextLabel(moneyBagInfo[MoneybagID][bagLabel]); 
        Moneybagid = -1; 
        MessageAll(-1, "{cafca6}[Moneybag] {FFFFFF}Shit! The event has ended, no one found the Moneybag"); 
    } 
    else 
    { 
        new randomBag = random(MAX_BAG_LOCATIONS), world = moneyBagInfo[randomBag][bagWorld]; 
  
        moneyBagInfo[randomBag][bagID] = CreatePickup(1550, 23, moneyBagInfo[randomBag][bagXYZ][0], moneyBagInfo[randomBag][bagXYZ][1], moneyBagInfo[randomBag][bagXYZ][2], world); 
        //moneyBagInfo[randomBag][bagLabel] = CreateDynamic3DTextLabel("[Moneybag]", COLOR_YELLOW, moneyBagInfo[randomBag][bagXYZ][0], moneyBagInfo[randomBag][//bagXYZ][1], moneyBagInfo[randomBag][bagXYZ][2] - 0.1, 40.0, .worldid = 5, .interiorid = 13); 
        Moneybagid = randomBag;         
        MessageAll(-1, "{cafca6}[Moneybag] {FFFFFF} A Moneybag is hidden inside {FFDC2E}%s{FFFFFF}!", moneyBagInfo[randomBag][bagTitle]); 
    } 
} 

/* Place this where you want to stop said timer */ 

if(AutoMoneyBag!= Timer:-1) 
{ 
    stop AutoMoneyBag; 
    AutoMoneyBag= Timer:-1; 
} 
else 
{ 
    printf("The timer is already long gone!")
}
Thank you sir.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)