Klages 10 Posted April 19, 2013 hello everyone! i tried to make a script that forces the playerview in Vehicles to First-Person. what i got is this: while {true} do {if(vehicle player != player) then {player switchCamera "Internal";};sleep 0.5;}; with this code the player is able to play in First-Person and third-Person while on feet, as soon as the player gets in a vehicle the camera should change to First-Person (Internal). the problem with this piece of code is that if i get in a vehicle the camera stays out of the vehicle. when i try do drive away the camera stays still at the point from which i got in the vehicle. can please anybody help me out with this? i guess its just a small thing or somethingi just dont know. cheers! Share this post Link to post Share on other sites
killzone_kid 1333 Posted April 19, 2013 Maybe try (vehicle player) switchCamera "INTERNAL" Also your script will automatically quit after 83.3333 minutes as while can only do 10000 iterations. Share this post Link to post Share on other sites
Klages 10 Posted April 19, 2013 Maybe try (vehicle player) switchCamera "INTERNAL"Also your script will automatically quit after 83.3333 minutes as while can only do 10000 iterations. works like i wanted it thanks! if it quits after 83.3333 minutes, how can i manage this function to work infinite? (its for a dayz server) Share this post Link to post Share on other sites
killzone_kid 1333 Posted April 19, 2013 infinite? don't think it is possible but to make it work longer put while loop inside while loop Share this post Link to post Share on other sites
xxanimusxx 2 Posted April 19, 2013 There is no limitation to how much loops a while can do, this was due to some bug it seems but it has been fixed ages ago :D 5134 - Fixed: Limit of iterations in while cycle no longer applied for scripts ran through execVM or spawn I just put this lines of code into the init.sqf and it worked like a charm even for more than 10k: _counter = 0; while {true} do { _counter = _counter + 1; hintsilent str _counter; }; The other option would have been putting your while into a function and counting the loop interations and upon reaching 9999 you'd stop the while-loop and call the function again. But you don't have to worry bout that, no limitations are set. Share this post Link to post Share on other sites
killzone_kid 1333 Posted April 19, 2013 Nice to know. I know it definitely limited to 10000 with call. init.sqf is not called though. Share this post Link to post Share on other sites
xxanimusxx 2 Posted April 19, 2013 Hmm now I'm confused, I just called the code I posted above (wrapped in a "call { .... }") and it still counted way above 100k. So can I assume that there is no limitations i direct (call) and asynchronus (spawn/execVM) calls or did I just do something wrong? :S Share this post Link to post Share on other sites
killzone_kid 1333 Posted April 19, 2013 if I call {} it i get 10000. I guess you are either execVM your code or spawn it. null = [] spawn {call {while {true} do {}}} is infinite Share this post Link to post Share on other sites
xxanimusxx 2 Posted April 19, 2013 I put exactly this code into the top of my init.sqf AND in a script which gets called when I pick an action I attached to my player. _myWhile = { _counter = 0; while {true} do { _counter = _counter + 1; hintsilent str _counter; }; }; call _myWhile; hint "Done!"; As prove that this is a legitimate call the last hint "Done" never gets shown or heared. In both scripts the counter is way over 1 million. So how did you execute your while that it just loops 10k times? It would be very interesting to know if there really IS an limitation to consider. Share this post Link to post Share on other sites
killzone_kid 1333 Posted April 19, 2013 call script from fsm or event handler. as i said init sqf is not called so anything derived from it is not gonna be straight forward call. Share this post Link to post Share on other sites
killzone_kid 1333 Posted April 20, 2013 So how did you execute your while that it just loops 10k times? It would be very interesting to know if there really IS an limitation to consider. I've done some more research and summarised it here http://killzonekid.com/arma-scripting-tutorials-loops/ Share this post Link to post Share on other sites
iceman77 19 Posted October 4, 2013 Sorry for the necro, but does the same concept apply to waitUntil? If I spawn a script that contains a waitUntil, will it have unlimited iterations? Thanks. Share this post Link to post Share on other sites
PlacidPaul 11 Posted October 4, 2013 Not sure ice, but thought I would post a major disadvantage with only first person in vehicle. You can't aim down the iron sights. Unless someone knows a fix...... Share this post Link to post Share on other sites
iceman77 19 Posted October 5, 2013 Sorry for the necro, but does the same concept apply to waitUntil? If I spawn a script that contains a waitUntil, will it have unlimited iterations? Thanks. Anyone? Need some clarification before I start down a road to nowhere... :cool: Share this post Link to post Share on other sites