get_players() returning wrong value
Sup, I'm trying to kick a random spec, but iNum (code below), is returning 0:
PHP Code:
PHP Code:
AMXX: AMX Mod X 1.8.3-dev+5106 |
Re: get_players() returning wrong value
You aren't printing iNum (in your other console_print), you are printing the return value of get_players() (which is irrelevant).
I don't see anything in your code that could give an index out of bounds error. Also, your CheckSpec() function makes no sense. |
Re: get_players() returning wrong value
I printed get_players() for check if it's format is correct, and it's printed 1 (its correct). Abou the sense, it's an example. I could not show the whole plugin ('cos it's 4k lines besides be private). But the code does not change anything "fatal" to return the iNum 0. CT and TERRORIST are returning correct, only SPECTATOR that isn't, idk why.
I did that to pick a random spec: PHP Code:
PHP Code:
The index out of bounds is 'cos the iNum returns 0: iRandomPlayer = iPlayers[random(iNum)] - It'll be 0 aways, and prints that: Code:
L 10/17/2017 - 00:00:01: [AMXX] Run time error 4: index out of bounds PHP Code:
|
Re: get_players() returning wrong value
In the original documentation for version 1.8.2, flags were stated as being deprecated for get_players() . Did they change that in 1.8.3-dev?
Quote:
Quote:
Quote:
|
Re: get_players() returning wrong value
Quote:
PHP Code:
Quote:
|
Re: get_players() returning wrong value
|
Re: get_players() returning wrong value
I just noticed that you have 2 same static variables in 2 functions
PHP Code:
Not sure tho if this is what causes your problem. |
Re: get_players() returning wrong value
Imagine you have 1 player on the server and he is in CT team. So, get_players in CheckSpec will return 1 player, then you check if him is CT or TR, if so you call kickRandomSpec and its get_players return 0 players, because you have only 1 CT which isn't a spectator.
random(0) is like random_num(0, -1), so its invalid and looks like its returning negative value. |
Re: get_players() returning wrong value
Quote:
Quote:
|
Re: get_players() returning wrong value
You can easily check if theres spec in one function i really dont understand why do you need two functions to do this
PHP Code:
You can just do this... |
All times are GMT -4. The time now is 14:27. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.