Wiebrendh Posted June 22, 2014 Share Posted June 22, 2014 So, is it possible to store 7 peds in one array, and then game task for those 7 peds with that array, so i dont have to set 7 tasks? Link to comment Share on other sites More sharing options...
Noox Posted June 22, 2014 Share Posted June 22, 2014 (edited) Uhm could you explain that a little better? Anyway, if I understood correct a for loop should do that Ped[] peds = new Ped[7];for(int i = 0; i < 7; i++) //i is the index{ peds[i].Task.Something() } Works the same with a while loop int i = 0;while(i < 7){ peds[i].Task.Something() i++} Edited June 22, 2014 by Noox Link to comment Share on other sites More sharing options...
Jitnaught Posted June 22, 2014 Share Posted June 22, 2014 Uhm could you explain that a little better? Anyway, if I understood correct a for loop should do that Ped[] peds = new Ped[7];for(int i = 0; i < 7; i++) //i is the index{ peds[i].Task.Something() }Works the same with a while loopint i = 0;while(i < 7){ peds[i].Task.Something() i++} Or use foreach. Link to comment Share on other sites More sharing options...
Noox Posted June 22, 2014 Share Posted June 22, 2014 Uhm could you explain that a little better? Anyway, if I understood correct a for loop should do that Ped[] peds = new Ped[7];for(int i = 0; i < 7; i++) //i is the index{ peds[i].Task.Something() }Works the same with a while loopint i = 0;while(i < 7){ peds[i].Task.Something() i++} Or use foreach. Uhm, doesn't foreach repeat everything until the objects in the condition are not in the array? The only time I used it I did in the main tick so I don't know. Link to comment Share on other sites More sharing options...
Jitnaught Posted June 22, 2014 Share Posted June 22, 2014 Uhm could you explain that a little better? Anyway, if I understood correct a for loop should do that Ped[] peds = new Ped[7];for(int i = 0; i < 7; i++) //i is the index{ peds[i].Task.Something() }Works the same with a while loopint i = 0;while(i < 7){ peds[i].Task.Something() i++} Or use foreach.Uhm, doesn't foreach repeat everything until the objects in the condition are not in the array? The only time I used it I did in the main tick so I don't know.I believe it should work like your for and while loops, if I'm not mistaken. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now