for statements.
#1

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!
Reply
#2

Read this article: https://sampwiki.blast.hk/wiki/Loops
Reply
#3

Hmm...ThAnKs!
Reply
#4

But do you want an countdown?

Then you would need to read about https://sampwiki.blast.hk/wiki/SetTimerEx
Reply
#5

I haven't timers with for statement before so can you please explain me with small codes.
ThAnKs!
Reply
#6

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]);
   }
}
Reply
#7

Thanks but can you do it with loops for me?the for statement.
ThAnKs!
Reply
#8

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);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)