do - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: do (
/showthread.php?tid=222085)
do -
CyNiC - 06.02.2011
Could someone tell me where it is recommended to use "do"?
I saw this in sscanf and did not understand perfectly what he does.
Re: do -
dice7 - 06.02.2011
https://sampwiki.blast.hk/wiki/While#do
Re: do -
Finn - 06.02.2011
do is used in a while loop.
pawn Код:
do
{
this();
}
while(this is true)
Edit: This forum doesn't give the warning if someone has posted meanwhile?
Re: do -
iFriSki - 06.02.2011
I may have my terminology off here, but a
do while loop is a post test loop, whereas a
while loop is a pretest loop. That being, a
do while loop will always execute at least once and then check the condition, whereas a
while loop checks the condition then performs its tasks.
Re: do -
Miguel - 06.02.2011
An example of its use is the code to get a random player:
pawn Код:
new
playerid;
do
{
playerid = random(MAX_PLAYERS);
}
while(!IsPlayerConnected(playerid));
The value of "playerid" is set to a random value between 0 and 499. If the player with that ID (the random value) isn't connected, do it again. Do this, if it didn't work, do it again, if it didn't work, do it once again; that's how it works. However, I suggest you to not use that code, because that could freeze your server if there are now players connected.
Re: do -
CyNiC - 06.02.2011
Everyone helped me to understand, I now know when and how to use, grateful.