Quote:
Originally Posted by Moody92
I think I've understood about player indexes, so we need to put it [32] always to avoid mixing up with their numbers
|
PHP Code:
// As I said before, player indexes ranges from 1 two 32
// Lets say you made a new array with 32 rows
new iArray[32]
// and id = 32
// Now if you did this it will give you an error (Index out of bounds)
iArray[id] = 5
server_print("%d", iArray[id])// And this function won't work
// What happened here that it gave an error because there is no such a row with the number 32 in Array
// Arrays ranges from 0 to (Whatever you assign the array with) - 1
// So to make it correct, you must declare the array with 33 rows (last row is 32)
new iArray[33]
iArray[id] = 5
server_print("%d", iArray[id]) // This would print in server console 5
You just declare the array (that you are going to use with get_players) with 32 rows, because that's how the function works
PHP Code:
new players[32], count
get_players(players, count)
/*
if count == 5
Then players will look like this
players[0] = 1
players[1] = 2
players[2] = 3
players[3] = 4
players[4] = 5
*/
__________________