YSI Timer and Foreach
#1

I'm having a bit of problem with using ******' timers and foreach. They just don't work and I've given up hope, so I would really appreciate some help.

I tested it out by having this code:
pawn Код:
#include    <foreach>
#include    <YSI\y_timers>

timer OneSecond[1000]()
{
    foreach(new i : Player)
    {
        if(IsPlayerConnected(i))
        {
            SendClientMessage(i, 0xFFFFFFFF, ".");
        }
    }
}
Compiled without any errors or warnings, but nothing happens as well.
Reply
#2

I have tested foreach again, it works fine. Now it's just the timers. I tried using this format:
pawn Код:
Timer:OneSecond[1000]()
{

}
But it says "(9923) : error 010: invalid function or declaration"
Reply
#3

PHP код:
timer CallTimer[1000]()
{
    
Works only if its called Scriptwise.
    
blablabla
}

task FullTimeTimer[1000]()
{
    
Works when the server is up and keeps running
    
foreach
    {
        
blablabla
    
}
}

ptask OnlinePlayerTimer[1000](playerid)
{
    
Works when a player connects and keeps running till he logs
}

//How timer[]() works.

new Timer:TimerID;
CMD:lol(playeridparams[])
{
    
TimerID=repeat CallTimer();
    return 
1;
}

CMD:endlol(playeridparams[])
{
    
stop TimerID;
    return 
1;

Refer y_timer again: https://sampforum.blast.hk/showthread.php?tid=182948
Reply
#4

Edit: Nevermind, stupid me. Thanks though!

pawn Код:
task Timer[1000]() { }
Reply
#5

If your using YSI don't use foreach use #include <YSI\y_iterate>
Reply
#6

Quote:
Originally Posted by Pottus
Посмотреть сообщение
If your using YSI don't use foreach use #include <YSI\y_iterate>
Oh thank you. But would this still work?:

pawn Код:
foreach(Player, i)
{

}
And also, I've seen some threads where they use such:
pawn Код:
Timer:TimerName[1000]()
{

}
How do they make that work instead of this:
pawn Код:
task TimerName[1000]()
{

}
Reply
#7

Timer: was an old version of y_timers...

Now to define a timer, You use: timer FuncName[time](params) { CODE }

And to save its ID for repeating you use:
pawn Код:
new Timer:TimerID;

//Start
TimerID = repeat FuncName(params);

//Stop
stop TimerID;
Reply
#8

Quote:
Originally Posted by Ahmad45123
Посмотреть сообщение
Timer: was an old version of y_timers...

Now to define a timer, You use: timer FuncName[time](params) { CODE }

And to save its ID for repeating you use:
pawn Код:
new Timer:TimerID;

//Start
TimerID = repeat FuncName(params);

//Stop
stop TimerID;
I've tried to use "timer" but it didn't work. What I'm trying to do is to have a recurring timer. Somehow, using the code below worked for me.
pawn Код:
task TimerName[1000]()
{

}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)