04.08.2015, 18:45
Okay, so you have an array index. It's a value from 0 to 6 because you have seven fields in your array.
You want to get an index, a place in the array, which is empty, which means no player ID is stored there.
That's why you need to set slot to -1 because that is an invalid index. Go through the array and check if some value is equal to -1, which means it's empty and assign that field to the slot variable.
After the loop you want to see if you've got an empty slot. If not, player won't be able to join the event.
If you would do this:
new slot; // slot is by default zero
and you go through the array and you don't find any empty slot, your slot variable would still be zero and you would override EventPlayer[0] to current player's ID.
You want to get an index, a place in the array, which is empty, which means no player ID is stored there.
That's why you need to set slot to -1 because that is an invalid index. Go through the array and check if some value is equal to -1, which means it's empty and assign that field to the slot variable.
After the loop you want to see if you've got an empty slot. If not, player won't be able to join the event.
If you would do this:
new slot; // slot is by default zero
and you go through the array and you don't find any empty slot, your slot variable would still be zero and you would override EventPlayer[0] to current player's ID.