YSI Timer and Foreach -
Eyce - 24.12.2014
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.
Re: YSI Timer and Foreach -
Eyce - 24.12.2014
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"
Re: YSI Timer and Foreach -
Mic_H - 25.12.2014
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(playerid, params[])
{
TimerID=repeat CallTimer();
return 1;
}
CMD:endlol(playerid, params[])
{
stop TimerID;
return 1;
}
Refer y_timer again:
https://sampforum.blast.hk/showthread.php?tid=182948
Re: YSI Timer and Foreach -
Eyce - 25.12.2014
Edit: Nevermind, stupid me. Thanks though!
Re: YSI Timer and Foreach -
Pottus - 25.12.2014
If your using YSI don't use foreach use #include <YSI\y_iterate>
Re: YSI Timer and Foreach -
Eyce - 25.12.2014
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?:
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]()
{
}
Re: YSI Timer and Foreach -
Ahmad45123 - 25.12.2014
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;
Re: YSI Timer and Foreach -
Eyce - 26.12.2014
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.