ok thx that helps alot but maan i'm so overchallenged right now haha
what i want to do is to add a flag for certain commands in a config file from which a menu gets build
so the cfg is like that:
PHP Code:
"Donor"
{
"Graffitis"
{
"items"
{
"sm_sprays" "!sprays - Choose a graffiti"
}
}
"Chatcolors and Chattag"
{
"items"
{
"sm_changetag" "!changetag - Change your Tag"
"sm_colors" "!colors - Change your Tag-Name-Chat-color"
}
}
}
i need to add a flag like this:
PHP Code:
"Donor"
{
"Graffitis"
{
"items"
{
"sm_sprays" "!sprays - Choose a graffiti" "Admin_Custom3"
}
}
"Chatcolors and Chattag"
{
"items"
{
"sm_changetag" "!changetag - Change your Tag" "Admin_Custom4"
"sm_colors" "!colors - Change your Tag-Name-Chat-color" "Admin_Custom3"
}
}
}
then somewhere in this parser section i need to read out the flag but i have no idea where and how -.-
PHP Code:
public OnMapStart() {
new String:hc[PLATFORM_MAX_PATH];
BuildPath(Path_SM, hc, sizeof(hc), "configs/donors.cfg");
ParseConfigFile(hc);
}
bool:ParseConfigFile(const String:file[]) {
if (g_DonorMenus != INVALID_HANDLE) {
ClearArray(g_DonorMenus);
CloseHandle(g_DonorMenus);
g_DonorMenus = INVALID_HANDLE;
}
new Handle:parser = SMC_CreateParser();
SMC_SetReaders(parser, Config_NewSection, Config_KeyValue, Config_EndSection);
SMC_SetParseEnd(parser, Config_End);
new line = 0;
new col = 0;
new String:error[128];
new SMCError:result = SMC_ParseFile(parser, file, line, col);
CloseHandle(parser);
if (result != SMCError_Okay) {
SMC_GetErrorString(result, error, sizeof(error));
LogError("%s on line %d, col %d of %s", error, line, col, file);
}
return (result == SMCError_Okay);
}
public SMCResult:Config_NewSection(Handle:parser, const String:section[], bool:quotes) {
g_configLevel++;
if (g_configLevel == 1) {
new hmenu[DonorMenu];
strcopy(hmenu[dname], sizeof(hmenu[dname]), section);
hmenu[items] = CreateDataPack();
hmenu[itemct] = 0;
if (g_DonorMenus == INVALID_HANDLE)
g_DonorMenus = CreateArray(sizeof(hmenu));
PushArrayArray(g_DonorMenus, hmenu[0]);
}
return SMCParse_Continue;
}
public SMCResult:Config_KeyValue(Handle:parser, const String:key[], const String:value[], bool:key_quotes, bool:value_quotes) {
new msize = GetArraySize(g_DonorMenus);
new hmenu[DonorMenu];
GetArrayArray(g_DonorMenus, msize-1, hmenu[0]);
switch (g_configLevel) {
case 1: {
if(strcmp(key, "title", false) == 0)
strcopy(hmenu[title], sizeof(hmenu[title]), value);
if(strcmp(key, "type", false) == 0) {
if(strcmp(value, "text", false) == 0)
hmenu[type] = DonorMenuType_Text;
else
hmenu[type] = DonorMenuType_List;
}
}
case 2: {
WritePackString(hmenu[items], key);
WritePackString(hmenu[items], value);
hmenu[itemct]++;
}
}
SetArrayArray(g_DonorMenus, msize-1, hmenu[0]);
return SMCParse_Continue;
}
public SMCResult:Config_EndSection(Handle:parser) {
g_configLevel--;
if (g_configLevel == 1) {
new hmenu[DonorMenu];
new msize = GetArraySize(g_DonorMenus);
GetArrayArray(g_DonorMenus, msize-1, hmenu[0]);
ResetPack(hmenu[items]);
}
return SMCParse_Continue;
}
public Config_End(Handle:parser, bool:halted, bool:failed) {
if (failed)
SetFailState("DonorMenu: Plugin Configuration Error");
}
then i need to do the if statement in here i guess marked with ////////////////////////////
PHP Code:
public Help_MainMenuHandler(Handle:menu, MenuAction:action, param1, param2) {
if (action == MenuAction_End) {
CloseHandle(menu);
} else if (action == MenuAction_Select) {
new msize = GetArraySize(g_DonorMenus);
if (param2 == msize) { // Admins
new Handle:adminMenu = CreateMenu(Help_MenuHandler);
SetMenuExitBackButton(adminMenu, true);
SetMenuTitle(adminMenu, "Online Admins\n ");
new maxc = GetMaxClients();
new String:aname[64];
for (new i = 1; i < maxc; ++i) {
if (IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i) && (GetUserFlagBits(i) & ADMFLAG_GENERIC) == ADMFLAG_GENERIC) {
GetClientName(i, aname, sizeof(aname));
AddMenuItem(adminMenu, aname, aname, ITEMDRAW_DISABLED);
}
}
DisplayMenu(adminMenu, param1, 30);
} else { // Menu from config file
if (param2 <= msize) {
new hmenu[DonorMenu];
GetArrayArray(g_DonorMenus, param2, hmenu[0]);
new String:mtitle[512];
Format(mtitle, sizeof(mtitle), "%s\n ", hmenu[title]);
if (hmenu[type] == DonorMenuType_Text) {
new Handle:cpanel = CreatePanel();
SetPanelTitle(cpanel, mtitle);
new String:text[128];
new String:junk[128];
for (new i = 0; i < hmenu[itemct]; ++i) {
ReadPackString(hmenu[items], junk, sizeof(junk));
ReadPackString(hmenu[items], text, sizeof(text));
DrawPanelText(cpanel, text);
}
for (new j = 0; j < 7; ++j)
DrawPanelItem(cpanel, " ", ITEMDRAW_NOTEXT);
DrawPanelText(cpanel, " ");
DrawPanelItem(cpanel, "Back", ITEMDRAW_CONTROL);
DrawPanelItem(cpanel, " ", ITEMDRAW_NOTEXT);
DrawPanelText(cpanel, " ");
DrawPanelItem(cpanel, "Exit", ITEMDRAW_CONTROL);
ResetPack(hmenu[items]);
SendPanelToClient(cpanel, param1, Help_MenuHandler, 30);
CloseHandle(cpanel);
} else {
new Handle:cmenu = CreateMenu(Help_CustomMenuHandler);
SetMenuExitBackButton(cmenu, true);
SetMenuTitle(cmenu, mtitle);
new String:cmd[128];
new String:desc[128];
for (new i = 0; i < hmenu[itemct]; ++i) {
ReadPackString(hmenu[items], cmd, sizeof(cmd));
ReadPackString(hmenu[items], desc, sizeof(desc));
new drawstyle = ITEMDRAW_DEFAULT;
if (strlen(cmd) == 0)
drawstyle = ITEMDRAW_DISABLED;
/////////////////////////if client has flag from config file then drawstyle = ITEMDRAW_DEFAULT else drawstyle = ITEMDRAW_DISABLED ////////////////////////////
AddMenuItem(cmenu, cmd, desc, drawstyle);
}
ResetPack(hmenu[items]);
DisplayMenu(cmenu, param1, 30);
}
}
}
}
}
i hope someone can help me