Guys i need to read list of strings from file and want to store it in array but im unable to do that
PHP Code:
const MAX_LEVELS = 100;
enum _:LevelData {
LD_Level
};
new data[LevelData]
public plugin_init()
{
CreateNamesArray()
}
public CreateNamesArray()
{
get_configsdir(g_szLevFile, charsmax(g_szLevFile)); //gets addons/amxmodx/configs directory
format(g_szLevFile, charsmax(g_szLevFile), "%s/ps_levels.ini", g_szLevFile); //formats the file name for the Weapons order INI
g_FilePointer = fopen(g_szLevFile, "r"); //Opens the file
tlevels = ArrayCreate(LevelData);
new szData[32];
new lev[32]
if(g_FilePointer) //Makes sure the files open
{
while(!feof(g_FilePointer))
{
fgets(g_FilePointer, szData, charsmax(szData)); //Reads a line of the file
trim(szData); //Removes '^n' new line character from the end of the line
if(containi(szData, ";") != -1) //Checks to see if its a comment and then ignores it
continue;
parse(szData, lev, 31)
data[LD_Level] = str_to_num(lev);
if(sizeEntries < MAX_LEVELS)
{
// add it to the end
ArrayPushArray(tlevels, data);
sizeEntries++;
}
}
}
fclose(g_FilePointer);
}
public show_xp(id)
{
ArrayGetArray(tlevels, gxp[id], data);
client_print_color(id,id,"your class is %s",data[LD_Level] )
}
This is my code basically what i want is instead of creating an array of level classes like
new const Prefix[MaxLevels +2][] =
{
"Newbie", // 0
"Noob", // 15
"Playah", // 40
"Semi-Pro", // 75
"Senior", // 130
"PIMP", // 200
"GangLeader", // 300
"Global Assasin", // 450
"Chuck Norris", // 650
"Veteran", // 1000
}
I want this to be written in a ini file so that anyone can modify it nd i want to read that ini file den store the class names in an array like the above array has 9 classes for 9 levels so i want to display respective class names for respective levels so pls suggest modification in my code
