for statements. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: for statements. (
/showthread.php?tid=375281)
for statements. -
TaLhA XIV - 06.09.2012
Hello,
I wanted someone to tell me about "for" statements.You all may know about "for" like for(blabla=10;blabla>=1;blabla--),
I looked this thype of some codes in a script so can someone explain me like,it sends a player message 10 then 9 then 8,etc,hope you understand.
ThAnKs!
Re: for statements. -
Cameltoe - 06.09.2012
Read this article:
https://sampwiki.blast.hk/wiki/Loops
Re: for statements. -
TaLhA XIV - 06.09.2012
Hmm...ThAnKs!
Re: for statements. -
Cameltoe - 06.09.2012
But do you want an countdown?
Then you would need to read about
https://sampwiki.blast.hk/wiki/SetTimerEx
Re: for statements. -
TaLhA XIV - 06.09.2012
I haven't timers with for statement before so can you please explain me with small codes.
ThAnKs!
Re: for statements. -
leonardo1434 - 06.09.2012
here's a simple countdown.
pawn Код:
// a little test to show you how it works.
public OnFilterScriptInit()
{
new p;
countdown(p,10);
}
new timer[MAX_PLAYERS];
forward countdown(playerid,number);
public countdown(playerid,number)
{
if(number > 0)
{
--number;
printf(#%d,number);
timer[playerid] = SetTimerEx("countdown",1000,false,"ii",playerid,number);
}
else
{
KillTimer(timer[playerid]);
}
}
Re: for statements. -
TaLhA XIV - 06.09.2012
Thanks but can you do it with loops for me?the for statement.
ThAnKs!
Re: for statements. -
leonardo1434 - 06.09.2012
count with loop? just a remind, this is a loop. it interact each second thousands of times.
pawn Код:
contloop(start,end)
{
for(; start < end; ++start)
{
printf(#%d,start);
}
}
// usage
contloop(5,10);