diff --git a/plugins/adminmenu/dynamicmenu.sp b/plugins/adminmenu/dynamicmenu.sp index c4e89977..1a109ef8 100644 --- a/plugins/adminmenu/dynamicmenu.sp +++ b/plugins/adminmenu/dynamicmenu.sp @@ -81,7 +81,7 @@ BuildDynamicMenu() new Handle:kvMenu; kvMenu = CreateKeyValues("Commands"); - KvSetEscapeSequences(kvMenu, true); + KvSetEscapeSequences(kvMenu, true); new String:file[256]; @@ -284,8 +284,7 @@ BuildDynamicMenu() else { submenuInput[Submenu_method] = Name; - } - + } } KvGetString(kvMenu, "title", inputBuffer, sizeof(inputBuffer)); @@ -586,13 +585,16 @@ public ParamCheck(client) DisplayTopMenu(hAdminMenu, client, TopMenuPosition_LastCategory); + decl String:unquotedCommand[CMD_LENGTH]; + UnQuoteString(g_command[client], unquotedCommand, sizeof(unquotedCommand), "#@"); + if (outputItem[Item_execute] == Execute_Player) // assume 'player' type execute option { - FakeClientCommand(client, g_command[client]); + FakeClientCommand(client, unquotedCommand); } else // assume 'server' type execute option { - InsertServerCommand(g_command[client]); + InsertServerCommand(unquotedCommand); ServerExecute(); } @@ -610,16 +612,20 @@ public Menu_Selection(Handle:menu, MenuAction:action, param1, param2) if (action == MenuAction_Select) { - new String:info[NAME_LENGTH]; + new String:unquotedinfo[NAME_LENGTH]; /* Get item info */ - new bool:found = GetMenuItem(menu, param2, info, sizeof(info)); + new bool:found = GetMenuItem(menu, param2, unquotedinfo, sizeof(unquotedinfo)); if (!found) { return; } + new String:info[NAME_LENGTH*2+1]; + QuoteString(unquotedinfo, info, sizeof(info), "#@"); + + new String:buffer[6]; new String:infobuffer[NAME_LENGTH+2]; Format(infobuffer, sizeof(infobuffer), "\"%s\"", info); @@ -644,3 +650,72 @@ public Menu_Selection(Handle:menu, MenuAction:action, param1, param2) DisplayTopMenu(hAdminMenu, param1, TopMenuPosition_LastCategory); } } + + +stock bool:QuoteString(String:input[], String:output[], maxlen, String:quotechars[]) +{ + new count = 0; + new len = strlen(input); + + for (new i=0; i= maxlen) + { + /* Null terminate for safety */ + output[maxlen-1] = 0; + return false; + } + + if (FindCharInString(quotechars, input[i]) != -1 || input[i] == '\\') + { + /* This char needs escaping */ + output[count] = '\\'; + count++; + + if (count >= maxlen) + { + /* Null terminate for safety */ + output[maxlen-1] = 0; + return false; + } + } + } + + output[count] = 0; + + return true; +} + +stock bool:UnQuoteString(String:input[], String:output[], maxlen, String:quotechars[]) +{ + new count = 1; + new len = strlen(input); + + output[0] = input[0]; + + for (new i=1; i= maxlen) + { + /* Null terminate for safety */ + output[maxlen-1] = 0; + return false; + } + } + + output[count] = 0; + + return true; +}