Posts: 248
Threads: 66
Joined: Dec 2010
Reputation:
0
Using for(the loop) and foreach in the same script can make the for loops not work? Because I'm using a timer repeating every second which contains a for loop and it doesn't work at all.
Note: for loops in my script don't work only in callbacks called by a timer.
Posts: 248
Threads: 66
Joined: Dec 2010
Reputation:
0
Well, it means that it's caused by something else.. So the problem is that loops (for, not foreach) don't work in callbacks called by a timer, but work fine in commands, default callbacks, etc.
Do you know what's the cause? I can paste the code, if you need it.
Posts: 248
Threads: 66
Joined: Dec 2010
Reputation:
0
I used exactly the same code in the past, and it worked... Oh, and when I run the server on my computer it works just fine. On the host(linux, ~80 players) it doesn't.
Posts: 2,421
Threads: 52
Joined: Mar 2009
Reputation:
0
I had some weird thing happen like this when i accessed an array out of bounds at runtime. Random things would just stop working. I also noticed it because it stopped all my timers from working.
I had a variable that counts vehicles as they are created, and i used that variable as an index to an array. I forgot to reset the var when the vehicles were destroyed, which led to indexing an array OOB at runtime. Can be a pain in the ass to find this kind of bug because when you think it's a bug in your code you seldom look at array sizes.
I'm not saying this IS your problem, just saying it may be.
Posts: 248
Threads: 66
Joined: Dec 2010
Reputation:
0
Can you give me an example code of this? I think I might have this problem, too