index out of bounds
Code:
this line -> Boss1 = players[ random( num ) ]; is giving me an "index out of bounds" error. Why? |
Re: index out of bounds
It does that when get_players() finds no players, resulting in a random( 0 ) call which will return a number outside the boundaries of your array, and is irrelevant for what you're doing.
Do this: PHP Code:
|
Re: index out of bounds
Because players[random(num)] has a value bigger r than Boss1supports. For example you declare boss[32] and players[random(num)] has 33 (bigger than 32).i had the same problem these days
|
Re: index out of bounds
Quote:
|
Re: index out of bounds
Quote:
But could you please explain why does it sometimes gives 0? For example I had a situation where we had 4 CTS and it gave me the result 0 and nothing happened next.. (my code didnt work) How can I fix it? |
Re: index out of bounds
Quote:
There are/were issues with get_players() when certain flags were passed. What AMX-X version are you running? If 1.8.2 or earlier then I suggest upgrading to a 1.8.3 build and see if it resolves your issue. I believe this was addressed in 1.8.3. If you search around the forums you will find a few threads regarding the problems with flags.. here's one: https://forums.alliedmods.net/showthread.php?t=256059 |
| All times are GMT -4. The time now is 22:13. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.