Call of Duty: Black Ops 3 => Help Desk => Scripting => Topic started by: Doodles_Inc on September 16, 2017, 08:31:29 pm
Title: Stop a loop?
Post by: Doodles_Inc on September 16, 2017, 08:31:29 pm
You might think that this is a joke, but, I really suck at scripting since I started it this week, and I need help so, after the loop is completed, he stops, thanks in advance! If you're wondering how my code is looking... here it is: https://pastebin.com/dJ45jkGa Double Post Merge: September 16, 2017, 10:54:21 pmMade it, you can see it in my pastebin.
Title: Re: Stop a loop?
Post by: Wolfilms on September 17, 2017, 03:52:52 pm
It looks like you are waiting for a player to enter 2 zones at once?
Title: Re: Stop a loop?
Post by: Doodles_Inc on September 17, 2017, 10:58:00 pm
It looks like you are waiting for a player to enter 2 zones at once?
Not at once, I managed to finish the script, I was only waiting for someone to answer so I could put this thread as solved.
Title: Re: Stop a loop?
Post by: Wolfilms on September 18, 2017, 12:08:45 am
oh ok
Title: Re: Stop a loop?
Post by: Archaicvirus on November 30, 2017, 01:23:41 am
I know you solved the issue, but I don't think you fully understand how while() loops work. Figured I'd explain a little to help you out.
Everything inside {curly braces} will loop forever until while(true) is evaluated as false - unless you call a break. It will work the way you're doing it (saw the pastebin, lol btw) however it is completely unnecessary if you call a wait() statement.
Basically, loops in general are intended to repeat or iterate a block of code until some condition is met. Logically if you're waiting() for a zone entrance, what code do you need to repeat? None. When you call waittill("zone_enter"), the script halts and does not process the next line until that notification is recieved, thus making a loop irrelevant. Then the next waittill("zone_enter") gets called and halts again until the player enters. So just get rid of the loop altogether, and write your code as normal. Ill give you a few examples for the sake of it. I'm no expert coder, but I can teach what I know.