Originally Posted By: hopfel
Make a 2D-array, fill it with the correct and with the entity- or bitmap-pointer:

Code:
var question[5][3]; //2D-Array, for 5 questions

...
function question_fill()
{

...
//fill the array for the first question
question[0][0] = 1; //the right answer is 1
question[0][1] = bmap_create("question.bmp"); //question-bitmap
question[0][2] = ent_create("answer_entity.mdl",nullevctor,NULL); // answer-entity

...
}


...

function question_ask()
{
var random_number = integer(random(4.9)); //make it random


...
if(my_answer == question[random_number][3])
{
((ENTITY*)question[0][2]).alpha = 100;
}
...

}



This example isn't complete, just to show you how you could do that. ^^
There are more ways, I guess, but I would do it that way. laugh
Hope it helps...
~greets
unsure why you're storing trying to store entities and bmaps in variables?

just create what you need as a struct then if you're not happy creating them dynamically or in an array then create them like so:
Code:
#include <acknex.h>
#include <default.c>

typedef struct RND_Q {
	BMAP* bmap;
	char* model;
	int answer;
} RND_Q;
RND_Q* rnd_q; //pointer for array of structs
int int_rndQuestionCount; //stores the number of random questions
int int_rndQuestionSelected;


//panel for displaying the question
PANEL* pnl_question = {
	flags = SHOW;
}

//function for adding question to the pool
void question_add(char* bmp, char* model, int answer){
	
	int i = int_rndQuestionCount;
	int_rndQuestionCount++;
	
	rnd_q = realloc(rnd_q, sizeof(RND_Q) * (int_rndQuestionCount));
	
	rnd_q[i].bmap = bmap_create(bmp);
	rnd_q[i].model = model;
	rnd_q[i].answer = answer;
}

void main(){
	
	wait(1);
	question_add("q01.bmp", "q01.mdl", 1);
	question_add("q02.bmp", "q02.mdl", 4);
	question_add("q03.bmp", "q03.mdl", 2);
	question_add("q04.bmp", "q04.mdl", 1);
	
	random_seed(0);
	
	int_rndQuestionSelected = random(integer(int_rndQuestionCount)); //randomly generates a question
	
	//rnd_q[int_rndQuestionSelected].bmap; //stores the question image
	//rnd_q[int_rndQuestionSelected].model; //stores the mode name
	//rnd_q[int_rndQuestionSelected].answer; //stores the correct answer
	
	//so to display the question in pnl_question use
	pnl_question.bmap = rnd_q[int_rndQuestionSelected].bmap;
}