Array problem
#1

Hi
I created an trivia system, with questions that I created in array.
Example:
pawn Code:
new triviaQuestions[][5][64] =
{
    {" Question 1?","answer 1","answer 2","answer 3","right answer number"},
    {" Question 2?","answer 1","answer 2","answer 3","right answer number"},
    {" Question 3?","answer 1","answer 2","answer 3","right answer number"},
    {" Question 4?","answer 1","answer 2","answer 3","right answer number"},
    {" Question 5?","answer 1","answer 2","answer 3","right answer number"}
};
But, when I'm trying to read something from this, it's give "".
pawn Code:
new q = random(sizeof(triviaQuestions))
    SendClientMessageToAll(green," Trivia:");
    SendClientMessageToAll(green,triviaQuestions[q][0]);
    //...
It's just send "Trivia:" and "" to all..
I'll be happy if someone will tell me why it's happen and how to fix it.

Thanks.
Reply
#2

I suggest using an enumerated array:

pawn Code:
enum trivia {
    Question [128],
    Answer1 [50],
    Answer2 [50],
    Answer3 [50],
    Correct
}
Then use:

pawn Code:
new triviaQuestions[][trivia] =
{
    {"Question 1?","answer 1","answer 2","answer 3","1"},
    {"Question 2?","answer 1","answer 2","answer 3","2"},
    {"Question 3?","answer 1","answer 2","answer 3","3"},
    {"Question 4?","answer 1","answer 2","answer 3","2"},
    {"Question 5?","answer 1","answer 2","answer 3","1"}
};
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)