Posts
145
Respect
38Add +1
Forum Rank
Pack-a-Puncher
Primary Group
Member
Login Issues
Forgot password?Activate Issues
Account activation email not received? Wrong account activation email used?Other Problems?
Contact Support - Help Center Get help on the UGX Discord. Join it now!It looks like you are waiting for a player to enter 2 zones at once?
![]() | Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum. |
//This example counts 10 player slide actions, prints the total to the screen, then breaks out of the loop & ends the function.
function example_loop()
{
slides = 0;
max_slides = 10;
players = GetPlayers();
player = players[0];
while(1)
{
if(player isSliding())
{
slides++;
IPrintLnBold("[" + slides + "] Slides have been detected");
if(slides >= max_slides)
{
break;
}
}
wait(1);
}
}
//This ex. uses a for() loop, counts & prints the array of zombies alive. You don't need a break statement as 'i' counts up with zombies.size.
//Once 'i' is greater than zombies.size, then middle statement in the loop becomes false, breaking the loop.
function example_loop2()
{
zombies = GetAISpeciesArray("axis", "all");
for(i = 0; i < zombies.size; i++)
{
IPrintLnBold("[" + i + 1 + "] zombies have been detected");
}
}
//Or you could do
function example_loop3()
{
i = 0;
foreach(zombie in GetAISpeciesArray("axis", "all"))
{
IPrintLnBold("[" + i + 1 + "] zombies have been detected");
i++;
}
}