Enum Error: error 008: must be a constant expression; assumed zero
#1

Hello again all,

So I have a MySQL database table containing info on all of the skins, including skin ids. I've created an Enum to store the skins. I have ran an sql query and am now trying to store each row of data into it's own enum. SO basically, looping through the result of skins that comes back from the database, and then foreach one create a new Skin Enum, with it's values inside. However, it's not working. My code is below:

Код:
enum sSkin{ //skins enum
	id,
	gender_id,
	model_name[50],
	name_type[100],
	is_private
}

forward OnSkinsLoaded();
public OnSkinsLoaded(){
	//This callback runs from OnGameModeInit, selecting all skins
	//Now set skin enum foreach skin
	if(mysql_errno() == 0){
	    new rowCount = cache_get_row_count(mysql);
    	if(rowCount){
            //character(s) found
            for(new i = 0; i < rowCount; i++){
                new skinID = cache_get_field_content_int(i, "id");	//get skin id from db
                new Skin[skinID][sSkin]; //Create skin enum for skin id
                Skin[skinID][gender_id] = cache_get_field_content_int(i, "gender_id");	//gender_id
			    cache_get_field_content(i, "model_name", Skin[skinID][model_name], mysql, 50);    //model_name
			    cache_get_field_content(i, "name_type", Skin[skinID][name_type], mysql, 100);    //name_type
			    Skin[skinID][is_private] = cache_get_field_content_int(i, "is_private");	//is skin private?
            }
		}
		return true;
	}else{
	    print("ERROR LOADING SKINS FROM MYSQL DATABASE");
	    return false;
	}
}
The error I'm recieving is:

Код:
..\include\systems\character\char_core.pwn(463) : error 008: must be a constant expression; assumed zero
Now, I know exactly what the issue is. It is "new Skin[skinID][sSkin]; //Create skin enum for skin id". It's because Pawno requires the value to be a constant where it says "[skinID]".

However, does anyone know a work around for this so I can have an enum for each of the skins loaded from this callback function ive made?

Many thanks
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)