Two dimensional string enum array
#1

Hi,

I would like to do something like this but it doesn't compile.. I just started to hate this fucking pawn since in last time I worked with plugins..

pawn Код:
enum e_HouseType
{
    e_szHouseName[2][24], <- THIS LINE ERROR
    e_iPrice
}

new const
    g_szHouseTypes[][e_HouseType] =
    {
        {"Fahбz",           "Tree house",   500000},
        {"Lakбs",           "House",                1000000},
        {"Banda hбz",       "Gang house",           2000000},
        {"Kis csalбdi hбz", "Small family house",   3000000},
        {"Tбrsashбz",       "Condominium",          3000000},
        {"Nagy csalбdi hбz","Big family house",     4500000},
        {"Nyaralу",         "Summer house",         5000000},
        {"Luxus hбz #1",    "Luxus house #1",       7500000},
        {"Luxus hбz #2",    "Luxus house #2",       10000000}
    };

C:\Users\Ati\Desktop\tesztszerver\filterscripts\extract.pwn(133) : error 001: expected token: "}", but found "["
I just started to translate my mode to English, and I need this solution:
pawn Код:
housename = g_szHouseTypes[type_id][language_id][e_szHouseName];
Reply
#2

Edit:

Your array is messed up, also only way i could think of:

Код:
enum e_HouseType
{
	e_szHName_eng[24],
	e_szHName_eng2[24],

	e_iPrice
}

new const
	g_szHouseTypes[][e_HouseType] =
	{
		{"Fahбz", 			"Tree house",			500000},
		{"Lakбs", 			"House",				1000000},
		{"Banda hбz", 		"Gang house", 			2000000},
		{"Kis csalбdi hбz",	"Small family house",	3000000},
		{"Tбrsashбz",		"Condominium",			3000000},
		{"Nagy csalбdi hбz","Big family house", 	4500000},
		{"Nyaralу", 		"Summer house",			5000000},
		{"Luxus hбz #1",	"Luxus house #1", 		7500000},
		{"Luxus hбz #2", 	"Luxus house #2",		10000000}
	};


housename = (!languageid) ? g_szHouseTypes[type_id][e_szHName_eng] : g_szHouseTypes[type_id][e_szHName_eng2];
Reply
#3

{"Fahбz", "Tree house", 500000},
Reply
#4

Ralfie: Thanks, but this is what I want to avoid. It would be easyer to just set up one dimension for every language, insted of new string variable. But I'm afraid that it's not possible because it's too much dimension.

Glenn332: Oh, I noticed it. Thanks but still doesn't work.
Reply
#5

Quote:
Originally Posted by kurta999
Посмотреть сообщение
Ralfie: Thanks, but this is what I want to avoid. It would be easyer to just set up one dimension for every language, insted of new string variable. But I'm afraid that it's not possible because it's too much dimension.
AFAIK, there's no other way to do this. You could make a function to extract the house name based on the language (Ralfie's array), to keep it shorter:
pawn Код:
GetHouseName( houseid, playerid )
    return (!Player[playerid][languageid]) ? g_szHouseTypes[type_id][e_szHName_eng] : g_szHouseTypes[type_id][e_szHName_eng2];
Reply
#6

Thanks. Then it's pawn limitation. I didn't want to do that but no other ways
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)