Store int value in an array
#1

I'm trying to store a value in an array but it doesn't work.

new Fish[MAX_PLAYERS][2];

At OnPlayerConnect I have Fish[playerid][0] = 0; and Fish[playerid][1] = 0;

In that 2 variables (I have 2 because a player can hold 2 fish) I want to store the type of fish which is from 0 to 9.
But when I try to store a fish type bigger than 1 I get:

[23:36:47] [debug] Run time error 4: "Array index out of bounds"
[23:36:47] [debug] Accessing element at index 2 past array upper bound 1

How can I store a value in that 2 fish variables?
Reply
#2

Show us the code where you set the variables.
Reply
#3

Solved.
I had a function GetFishName(id) and I used it like GetFishName(Fish[playerid][id]) instead of GetFishName(id).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)